@@ -83,22 +83,33 @@ def __init__(self, onQuery: Optional[Callable[[], Box]] = None, onSet: Optional[
8383 In this case, if your custom functions do not properly retrieve or set the actual window position and size, the
8484 information contained in the PyWinBox class, and returned by all properties, will likely become obsolete.
8585
86- It can raise ValueError if no parameters are passed.
86+ It can raise ValueError if no parameters or not valid window handle are passed
8787 """
88- self ._box : Box = Box (0 , 0 , 0 , 0 )
89- if handle is not None :
90- self ._handle = _getHandle (handle ) if handle is not None else None
91- elif onSet is None and onQuery is None :
88+ self ._handle = _getHandle (handle ) if handle is not None else None
89+ if self ._handle is None and (onSet is None or onQuery is None ):
9290 raise ValueError
9391 self ._onQuery : Callable [[], Box ] = onQuery or self .onQuery
9492 self ._onSet : Callable [[Box ], None ] = onSet or self .onSet
93+ self ._box : Box = Box (0 , 0 , 0 , 0 )
9594
9695 def onQuery (self ) -> Box :
96+ """
97+ Default method to retrieve current window position and size values when a property is queried.
98+ It requires to pass valid window handle when instantiating the main class (PyWinBox class)
99+
100+ :return: window Box struct (x, y, width, height)
101+ """
97102 if self ._handle is not None :
98103 self ._box = _getWindowBox (self ._handle )
99104 return self ._box
100105
101106 def onSet (self , newBox : Box ):
107+ """
108+ Default method to actually place / resize the window when a property is changed.
109+ It requires to pass valid window handle when instantiating the main class (PyWinBox class)
110+
111+ :param newBox: target position and or size in Box struct format (x, y, width, height)
112+ """
102113 if self ._handle is not None :
103114 _moveResizeWindow (self ._handle , newBox )
104115
@@ -114,7 +125,7 @@ def __repr__(self):
114125
115126 def __str__ (self ):
116127 """Return a string representation of this Box object."""
117- return "(%s, %s, w= %s, h= %s)" % (
128+ return "(%s, %s, %s, %s)" % (
118129 self ._box .left ,
119130 self ._box .top ,
120131 self ._box .width ,
0 commit comments