Skip to content

Commit 07bb48c

Browse files
committed
Added emwhlib
Fixed width/height calculations in Windows
1 parent 23f3685 commit 07bb48c

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

src/pywinbox/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
import sys
66
from collections.abc import Callable
7-
from typing import Union, Tuple, overload, Optional, NamedTuple
7+
from typing import Union, Tuple, NamedTuple
88

99
__all__ = [
1010
"version", "PyWinBox", "defaultOnQuery", "defaultOnSet", "Box", "Rect", "Point", "Size", "pointInBox"
1111
]
1212

13-
__version__ = "0.0.8"
13+
__version__ = "0.0.9"
1414

1515

1616
def version(numberOnly: bool = True):

src/pywinbox/_pywinbox_win.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _getHandle(handle: Union[int, str]) -> Optional[int]:
3333

3434
def _getWindowBox(handle: int) -> Box:
3535
x, y, r, b = win32gui.GetWindowRect(handle)
36-
return Box(x, y, abs(r - abs(x)), abs(b - abs(y)))
36+
return Box(x, y, abs(r - x), abs(b - y))
3737

3838

3939
def _moveResizeWindow(handle: int, newBox: Box):

tests/test_pywinbox.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,77 +55,96 @@ def test_basic():
5555
else:
5656
myPyBox = pywinbox.PyWinBox(onQuery=pywinbox.defaultOnQuery, onSet=pywinbox.defaultOnSet, handle=npw.getHandle())
5757

58+
print("INIT", npw.box, npw.rect)
5859

5960
myPyBox.left = 250
6061
time.sleep(timelap)
62+
print("LEFT", npw.box, npw.rect)
6163
assert npw.left == 250
6264

6365
myPyBox.right = 950
6466
time.sleep(timelap)
67+
print("RIGHT", npw.box, npw.rect)
6568
assert npw.right == 950
6669

6770
myPyBox.top = 150
6871
time.sleep(timelap)
72+
print("TOP", npw.box, npw.rect)
6973
assert npw.top == 150
7074

7175
myPyBox.bottom = 775
7276
time.sleep(timelap)
77+
print("BOTTOM", npw.box, npw.rect)
7378
assert npw.bottom == 775
7479

7580
myPyBox.topleft = (155, 350)
7681
time.sleep(timelap)
82+
print(npw.box, npw.rect)
7783
assert npw.topleft == (155, 350)
7884

7985
myPyBox.topright = (1000, 300)
8086
time.sleep(timelap)
87+
print(npw.box, npw.rect)
8188
assert npw.topright == (1000, 300)
8289

8390
myPyBox.bottomleft = (300, 975)
8491
time.sleep(timelap)
92+
print(npw.box, npw.rect)
8593
assert npw.bottomleft == (300, 975)
8694

8795
myPyBox.bottomright = (1000, 900)
8896
time.sleep(timelap)
97+
print(npw.box, npw.rect)
8998
assert npw.bottomright == (1000, 900)
9099

91100
myPyBox.midleft = (300, 400)
92101
time.sleep(timelap)
102+
print(npw.box, npw.rect)
93103
assert npw.midleft == (300, 400)
94104

95105
myPyBox.midright = (1050, 600)
96106
time.sleep(timelap)
107+
print(npw.box, npw.rect)
97108
assert npw.midright == (1050, 600)
98109

99110
myPyBox.midtop = (500, 350)
100111
time.sleep(timelap)
112+
print(npw.box, npw.rect)
101113
assert npw.midtop == (500, 350)
102114

103115
myPyBox.midbottom = (500, 800)
104116
time.sleep(timelap)
117+
print(npw.box, npw.rect)
105118
assert npw.midbottom == (500, 800)
106119

107120
myPyBox.center = (500, 350)
108121
time.sleep(timelap)
122+
print(npw.box, npw.rect)
109123
assert npw.center == (500, 350)
110124

111125
myPyBox.centerx = 1000
112126
time.sleep(timelap)
127+
print(npw.box, npw.rect)
113128
assert npw.centerx == 1000
114129

115130
myPyBox.centery = 600
116131
time.sleep(timelap)
132+
print(npw.box, npw.rect)
117133
assert npw.centery == 600
118134

119135
myPyBox.width = 700
120136
time.sleep(timelap)
137+
print(npw.box, npw.rect)
121138
assert npw.width == 700
122139

123140
myPyBox.height = 500
124141
time.sleep(timelap)
142+
print(npw.box, npw.rect)
125143
assert npw.height == 500
126144

127145
myPyBox.size = (801, 601)
128146
time.sleep(timelap)
147+
print(npw.box, npw.rect)
129148
assert npw.size == (801, 601)
130149

131150
# Test closing

0 commit comments

Comments
 (0)