wx.Rect

Inheritance diagram for wx.Rect:



Class API

Methods

__init__(x=0, y=0, width=0, height=0)

Create a new wx.Rect object.

Parameters:

  • x (int)
  • y (int)
  • width (int)
  • height (int)

Returns:

wx.Rect


CenterIn(r, dir=wx.BOTH)

Returns the rectangle having the same size as this one but centered relatively to the given rectangle r. By default, rectangle is centred in both directions but if dir includes only wx.VERTICAL or only wx.HORIZONTAL flag, then it is only centered in this direction while the other component of its position remains unchanged.

Parameters:


Returns:

wx.Rect


CentreIn(r, dir=wx.BOTH)

Returns the rectangle having the same size as this one but centered relatively to the given rectangle r. By default, rectangle is centred in both directions but if dir includes only wx.VERTICAL or only wx.HORIZONTAL flag, then it is only centered in this direction while the other component of its position remains unchanged.

Parameters:


Returns:

wx.Rect


Contains(x, y)

Returns True if the given rectangle is completely inside this rectangle (or touches its boundary) and False otherwise.

Parameters:

  • x (int)
  • y (int)

Returns:

bool


ContainsRect(rect)

Returns True if the given rectangle is completely inside this rectangle or touches its boundary.

Parameters:


Returns:

bool


ContainsXY(x, y)

Return True if the point is inside the rect.

Parameters:

  • x (int)
  • y (int)

Returns:

bool


Deflate(dx, dy)

Decrease the rectangle size.

This method is the opposite from Inflate: Deflate(a, b) is equivalent to Inflate(-a, -b). Please refer to Inflate for full description.

Parameters:

  • dx (int)
  • dy (int)

See also

Inflate


Get()

Return the rectangle properties as a tuple.


Returns:

(x, y, width, height)


GetBottom()

Gets the bottom point of the rectangle.


Returns:

int


GetBottomLeft()

Gets the position of the bottom left corner.


Returns:

wx.Point


GetBottomRight()

Gets the position of the bottom right corner.


Returns:

wx.Point


GetHeight()

Gets the height member.


Returns:

int


GetLeft()

Gets the left point of the rectangle (the same as GetX).


Returns:

int


GetPosition()

Gets the position.


Returns:

wx.Point


GetRight()

Gets the right point of the rectangle.


Returns:

int


GetSize()

Gets the size.


Returns:

wx.Size

See also

SetSize


GetTop()

Gets the top point of the rectangle (the same as GetY).


Returns:

int


GetTopLeft()

Gets the position of the top left corner of the rectangle, same as GetPosition.


Returns:

wx.Point


GetTopRight()

Gets the position of the top right corner.


Returns:

wx.Point


GetWidth()

Gets the width member.


Returns:

int


GetX()

Gets the x member.


Returns:

int


GetY()

Gets the y member.


Returns:

int


Inflate(dx, dy)

Increases the size of the rectangle.

The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note the the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.

The change is made to the rectangle inplace, if instead you need a copy that is inflated, preserving the original then make the copy first:

copy = wx.Rect(*original)
copy.Inflate(10, 15)

Parameters:

  • dx (int)
  • dy (int)

See also

Deflate


Intersect(rect)

Modifies the rectangle to contain the overlapping box of this rectangle and the one passed in as parameter. The version returns the new rectangle, the other one modifies this rectangle in place.

Parameters:


Returns:

wx.Rect


Intersects(rect)

Returns True if this rectangle has a non-empty intersection with the rectangle rect and False otherwise.

Parameters:


Returns:

bool


IsEmpty()

Returns True if this rectangle has a width or height less than or equal to 0 and False otherwise.


Returns:

bool


Offset(pt)

Same as OffsetXY but uses dx, dy from pt.

Parameters:


OffsetXY(dx, dy)

Moves the rectangle by the specified offset. If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.

Parameters:

  • dx (int)
  • dy (int)

Set(x=0, y=0, width=0, height=0)

Set all rectangle properties.

Parameters:

  • x (int)
  • y (int)
  • width (int)
  • height (int)

SetBottom(bottom)

Parameters:

  • bottom (int)

SetBottomLeft(p)

Parameters:


SetBottomRight(p)

Parameters:


SetHeight(height)

Sets the height.

Parameters:

  • height (int)

SetLeft(left)

Parameters:

  • left (int)

SetPosition(p)

Parameters:


SetRight(right)

Parameters:

  • right (int)

SetSize(s)

Sets the size.

Parameters:

See also

GetSize


SetTop(top)

Parameters:

  • top (int)

SetTopLeft(p)

Parameters:


SetTopRight(p)

Parameters:


SetWidth(width)

Sets the width.

Parameters:

  • width (int)

SetX(x)

Sets the x position.

Parameters:

  • x (int)

SetY(y)

Sets the y position.

Parameters:

  • y (int)

Union(rect)

Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. It returns the new rectangle.

Parameters:


Returns:

wx.Rect


Properties

Bottom
See GetBottom and SetBottom
BottomLeft
See GetBottomLeft and SetBottomLeft
BottomRight
See GetBottomRight and SetBottomRight
Empty
See IsEmpty
Height
See GetHeight and SetHeight
Left
See GetLeft and SetLeft
Position
See GetPosition and SetPosition
See GetRight and SetRight
Size
See GetSize and SetSize
Top
See GetTop and SetTop
TopLeft
See GetTopLeft and SetTopLeft
TopRight
See GetTopRight and SetTopRight
Width
See GetWidth and SetWidth
X
See GetX and SetX
Y
See GetY and SetY
bottom
See GetBottom and SetBottom
height
See GetHeight and SetHeight
left
See GetLeft and SetLeft
position
See GetPosition and SetPosition
right
See GetRight and SetRight
size
See GetSize and SetSize
top
See GetTop and SetTop
width
See GetWidth and SetWidth
x
See GetX and SetX
y
See GetY and SetY