locationHelper module
Classes and helper functions for working with rectangles and coordinates.
- class locationHelper.Point(x, y)
Bases:
Point
Represents a point on the screen.
Create new instance of Point(x, y)
- classmethod fromFloatCollection(*floats)
Creates an instance from float parameters. The provided parameters will be converted to ints automatically. @raise TypeError: If one of the input parameters isn’t a float.
- classmethod fromCompatibleType(point)
Creates an instance from a compatible type. Compatible types are defined in L{POINT_CLASSES}.
- classmethod fromDWORD(dwPoint)
- yWiseLessThan(other)
Returns whether self is less than other, first comparing y, then x coordinates. For example: (x=4,y=3) < (x=3,y=4) because self.y is less than other.y. To compare in opposite order (i.e. compare x, then y), use L{xWiseLessThan}
- xWiseLessThan(other)
Returns whether self is less than other, first comparing x, then y coordinates. For example: (x=3,y=4) < (x=4,y=3) because self.x is less than other.x. To compare in opposite order (i.e. compare y, then x), use L{yWiseLessThan}
- yWiseLessOrEq(other)
Returns whether self is less than or equal to other, first comparing y, then x coordinates. For example: (x=4,y=3) <= (x=3,y=4) because self.y is less than or equal to other.y. To compare in opposite order (i.e. compare x, then y), use L{xWiseLessOrEq}
- xWiseLessOrEq(other)
Returns whether self is less than or equal to other, first comparing x, then y coordinates. For example: (x=3,y=4) <= (x=4,y=3) because self.x is less than or equal to other.x. To compare in opposite order (i.e. compare y, then x), use L{yWiseLessOrEq}
- yWiseGreaterThan(other)
Returns whether self is greater than other, first comparing y, then x coordinates. For example: (x=3,y=4) > (x=4,y=3) because self.y is greater than other.y. To compare in opposite order (i.e. compare x, then y), use L{xWiseGreaterThan}
- xWiseGreaterThan(other)
Returns whether self is greater than other, first comparing x, then y coordinates. For example: (x=4,y=3) > (x=3,y=4) because self.x is greater than other.x. To compare in opposite order (i.e. compare y, then x), use L{yWiseGreaterThan}
- yWiseGreaterOrEq(other)
Returns whether self is greater than or equal to other, first comparing y, then x coordinates. For example: (x=3,y=4) >= (x=4,y=3) because self.y is greater than or equal to other.y. To compare in opposite order (i.e. compare x, then y), use L{xWiseGreaterOrEq}
- xWiseGreaterOrEq(other)
Returns whether self is greater than or equal to other, first comparing x, then y coordinates. For example: (x=4,y=3) >= (x=3,y=4) because self.x is greater than or equal to other.x. To compare in opposite order (i.e. compare y, then x), use L{yWiseGreaterOrEq}
- toPOINT()
Converts self to a L{ctypes.wintypes.POINT}
- toLogical(hwnd)
Converts self from physical to logical coordinates and returns a new L{Point}.
- toPhysical(hwnd)
Converts self from logical to physical coordinates and returns a new L{Point}
- toClient(hwnd)
Converts self from screen to client coordinates and returns a new L{Point}
- toScreen(hwnd)
Converts self from client to screen coordinates and returns a new L{Point}
- class locationHelper._RectMixin
Bases:
object
Mix-in class for properties shared between RectLTRB and RectLTWH classes
- classmethod fromFloatCollection(*floats)
Creates an instance from float parameters. The provided parameters will be converted to ints automatically. @raise TypeError: If one of the input parameters isn’t a float.
- classmethod fromCompatibleType(rect)
Creates an instance from a compatible type. Compatible types are defined in L{RECT_CLASSES}.
- classmethod fromPoint(point)
Creates an instance from a compatible point type with a width and height of 0.
- classmethod fromCollection(*items)
Creates a bounding rectangle for the provided collection of items. The highest coordinates found in the collection are considered exclusive. For example, if you provide Point(x=1,y=1) and point(x=2,y=2), The resulting rectangle coordinates are left=1,top=1,right=2,bottom=2. Input could be of mixed types from either L{RECT_CLASSES} or L{POINT_CLASSES}.
- toRECT()
Converts self to a L{ctypes.wintypes.RECT}
- toLogical(hwnd)
- toPhysical(hwnd)
- toClient(hwnd)
- toScreen(hwnd)
- property topLeft
- property topRight
- property bottomLeft
- property bottomRight
- property center
- isSubset(other)
Returns whether this rectangle is a subset of other (i.e. whether all points in this rectangle are contained by other).
- isSuperset(other)
Returns whether this rectangle is a superset of other (i.e. whether all points of other are contained by this rectangle).
- intersection(other)
Returns the intersection of self and other. For example, if self = Rect(left=10,top=10,right=25,bottom=25) and other = Rect(left=20,top=20,right=35,bottom=35), this results in Rect(left=20,top=20,right=25,bottom=25). No intersect results in a rectangle with zeroed coordinates.
- expandOrShrink(margin)
Expands or shrinks the boundaries of the rectangle with the given margin. For example, if self = Rect(left=10,top=10,right=25,bottom=25) and margin = 10, this results in Rect(left=0,top=0,right=35,bottom=35). If self = Rect(left=10,top=10,right=25,bottom=25) and margin = -5, this results in Rect(left=15,top=15,right=20,bottom=20).
- class locationHelper.RectLTWH(left, top, width, height)
Bases:
_RectMixin
,RectLTWH
Represents a rectangle on the screen, based on left and top coordinates, width and height. To represent a rectangle using left, top, right and bottom coordinates, use L{RectLTRB}.
Create new instance of RectLTWH(left, top, width, height)
- property right
- property bottom
- toLTRB()
- class locationHelper.RectLTRB(left, top, right, bottom)
Bases:
_RectMixin
,RectLTRB
Represents a rectangle on the screen. By convention, the right and bottom edges of the rectangle are normally considered exclusive. To represent a rectangle based on width and height instead, use L{RectLTWH}.
- property width
- property height
- toLTWH()
- locationHelper.POINT_CLASSES = (<class 'locationHelper.Point'>, <class 'ctypes.wintypes.POINT'>, <class 'wx._core.Point'>)
Classes which support conversion to locationHelper Points using their x and y properties. type: tuple
- locationHelper.RECT_CLASSES = (<class 'locationHelper.RectLTRB'>, <class 'locationHelper.RectLTWH'>, <class 'ctypes.wintypes.RECT'>)
Classes which support conversion to locationHelper RectLTRB/LTWH using their left, top, right and bottom properties. type: tuple