******* wx.Rect ******* Inheritance diagram for `wx.Rect`: | .. inheritance-diagram:: wx.Rect | Description =========== A class for manipulating rectangles. .. seealso:: `wx.Point `_, `wx.Size `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `CenterIn <#CenterIn>`_ * `CentreIn <#CentreIn>`_ * `Contains <#Contains>`_ * `ContainsRect <#ContainsRect>`_ * `ContainsXY <#ContainsXY>`_ * `Deflate <#Deflate>`_ * `Get <#Get>`_ * `GetBottom <#GetBottom>`_ * `GetBottomLeft <#GetBottomLeft>`_ * `GetBottomRight <#GetBottomRight>`_ * `GetHeight <#GetHeight>`_ * `GetLeft <#GetLeft>`_ * `GetPosition <#GetPosition>`_ * `GetRight <#GetRight>`_ * `GetSize <#GetSize>`_ * `GetTop <#GetTop>`_ * `GetTopLeft <#GetTopLeft>`_ * `GetTopRight <#GetTopRight>`_ * `GetWidth <#GetWidth>`_ * `GetX <#GetX>`_ * `GetY <#GetY>`_ * `Inflate <#Inflate>`_ * `Intersect <#Intersect>`_ * `Intersects <#Intersects>`_ * `IsEmpty <#IsEmpty>`_ * `Offset <#Offset>`_ * `OffsetXY <#OffsetXY>`_ * `Set <#Set>`_ * `SetBottom <#SetBottom>`_ * `SetBottomLeft <#SetBottomLeft>`_ * `SetBottomRight <#SetBottomRight>`_ * `SetHeight <#SetHeight>`_ * `SetLeft <#SetLeft>`_ * `SetPosition <#SetPosition>`_ * `SetRight <#SetRight>`_ * `SetSize <#SetSize>`_ * `SetTop <#SetTop>`_ * `SetTopLeft <#SetTopLeft>`_ * `SetTopRight <#SetTopRight>`_ * `SetWidth <#SetWidth>`_ * `SetX <#SetX>`_ * `SetY <#SetY>`_ * `Union <#Union>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Bottom <#Bottom>`_ * `BottomLeft <#BottomLeft>`_ * `BottomRight <#BottomRight>`_ * `Empty <#Empty>`_ * `Height <#Height>`_ * `Left <#Left>`_ * `Position <#Position>`_ * `Right <#Right>`_ * `Size <#Size>`_ * `Top <#Top>`_ * `TopLeft <#TopLeft>`_ * `TopRight <#TopRight>`_ * `Width <#Width>`_ * `X <#X>`_ * `Y <#Y>`_ * `bottom <#bottom>`_ * `height <#height>`_ * `left <#left>`_ * `position <#position>`_ * `right <#right>`_ * `size <#size>`_ * `top <#top>`_ * `width <#width>`_ * `x <#x>`_ * `y <#y>`_ Class API ========= Methods ^^^^^^^ .. method:: __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 `_ -------- .. method:: 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:** * `r` (`wx.Rect `_) * `dir` (int) | **Returns:** `wx.Rect `_ -------- .. method:: 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:** * `r` (`wx.Rect `_) * `dir` (int) | **Returns:** `wx.Rect `_ -------- .. method:: 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` -------- .. method:: ContainsRect(rect) Returns ``True`` if the given rectangle is completely inside this rectangle or touches its boundary. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `bool` -------- .. method:: ContainsXY(x, y) Return ``True`` if the point is inside the rect. **Parameters:** * `x` (int) * `y` (int) | **Returns:** `bool` -------- .. method:: Deflate(dx, dy) Decrease the rectangle size. This method is the opposite from `Inflate <#Inflate>`_: `Deflate(a, b)` is equivalent to `Inflate(-a, -b`). Please refer to `Inflate <#Inflate>`_ for full description. **Parameters:** * `dx` (int) * `dy` (int) .. seealso:: `Inflate <#Inflate>`_ -------- .. method:: Get() Return the rectangle properties as a tuple. | **Returns:** `(x, y, width, height)` -------- .. method:: GetBottom() Gets the bottom point of the rectangle. | **Returns:** `int` -------- .. method:: GetBottomLeft() Gets the position of the bottom left corner. | **Returns:** `wx.Point `_ -------- .. method:: GetBottomRight() Gets the position of the bottom right corner. | **Returns:** `wx.Point `_ -------- .. method:: GetHeight() Gets the height member. | **Returns:** `int` -------- .. method:: GetLeft() Gets the left point of the rectangle (the same as `GetX <#GetX>`_). | **Returns:** `int` -------- .. method:: GetPosition() Gets the position. | **Returns:** `wx.Point `_ -------- .. method:: GetRight() Gets the right point of the rectangle. | **Returns:** `int` -------- .. method:: GetSize() Gets the size. | **Returns:** `wx.Size `_ .. seealso:: `SetSize <#SetSize>`_ -------- .. method:: GetTop() Gets the top point of the rectangle (the same as `GetY <#GetY>`_). | **Returns:** `int` -------- .. method:: GetTopLeft() Gets the position of the top left corner of the rectangle, same as `GetPosition <#GetPosition>`_. | **Returns:** `wx.Point `_ -------- .. method:: GetTopRight() Gets the position of the top right corner. | **Returns:** `wx.Point `_ -------- .. method:: GetWidth() Gets the width member. | **Returns:** `int` -------- .. method:: GetX() Gets the x member. | **Returns:** `int` -------- .. method:: GetY() Gets the y member. | **Returns:** `int` -------- .. method:: 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) .. seealso:: `Deflate <#Deflate>`_ -------- .. method:: 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:** * `rect` (`wx.Rect `_) | **Returns:** `wx.Rect `_ -------- .. method:: Intersects(rect) Returns ``True`` if this rectangle has a non-empty intersection with the rectangle `rect` and ``False`` otherwise. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `bool` -------- .. method:: IsEmpty() Returns ``True`` if this rectangle has a width or height less than or equal to 0 and ``False`` otherwise. | **Returns:** `bool` -------- .. method:: Offset(pt) Same as `OffsetXY <#OffsetXY>`_ but uses `dx`, `dy` from `pt`. **Parameters:** * `pt` (`wx.Point `_) -------- .. method:: 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) -------- .. method:: Set(x=0, y=0, width=0, height=0) Set all rectangle properties. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) -------- .. method:: SetBottom(bottom) | **Parameters:** * `bottom` (int) -------- .. method:: SetBottomLeft(p) | **Parameters:** * `p` (`wx.Point `_) -------- .. method:: SetBottomRight(p) | **Parameters:** * `p` (`wx.Point `_) -------- .. method:: SetHeight(height) Sets the height. **Parameters:** * `height` (int) -------- .. method:: SetLeft(left) | **Parameters:** * `left` (int) -------- .. method:: SetPosition(p) | **Parameters:** * `p` (`wx.Point `_) -------- .. method:: SetRight(right) | **Parameters:** * `right` (int) -------- .. method:: SetSize(s) Sets the size. **Parameters:** * `s` (`wx.Size `_) .. seealso:: `GetSize <#GetSize>`_ -------- .. method:: SetTop(top) | **Parameters:** * `top` (int) -------- .. method:: SetTopLeft(p) | **Parameters:** * `p` (`wx.Point `_) -------- .. method:: SetTopRight(p) | **Parameters:** * `p` (`wx.Point `_) -------- .. method:: SetWidth(width) Sets the width. **Parameters:** * `width` (int) -------- .. method:: SetX(x) Sets the x position. **Parameters:** * `x` (int) -------- .. method:: SetY(y) Sets the y position. **Parameters:** * `y` (int) -------- .. method:: 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:** * `rect` (`wx.Rect `_) | **Returns:** `wx.Rect `_ -------- Properties ^^^^^^^^^^ .. attribute:: Bottom See `GetBottom <#GetBottom>`_ and `SetBottom <#SetBottom>`_ .. attribute:: BottomLeft See `GetBottomLeft <#GetBottomLeft>`_ and `SetBottomLeft <#SetBottomLeft>`_ .. attribute:: BottomRight See `GetBottomRight <#GetBottomRight>`_ and `SetBottomRight <#SetBottomRight>`_ .. attribute:: Empty See `IsEmpty <#IsEmpty>`_ .. attribute:: Height See `GetHeight <#GetHeight>`_ and `SetHeight <#SetHeight>`_ .. attribute:: Left See `GetLeft <#GetLeft>`_ and `SetLeft <#SetLeft>`_ .. attribute:: Position See `GetPosition <#GetPosition>`_ and `SetPosition <#SetPosition>`_ .. attribute:: Right See `GetRight <#GetRight>`_ and `SetRight <#SetRight>`_ .. attribute:: Size See `GetSize <#GetSize>`_ and `SetSize <#SetSize>`_ .. attribute:: Top See `GetTop <#GetTop>`_ and `SetTop <#SetTop>`_ .. attribute:: TopLeft See `GetTopLeft <#GetTopLeft>`_ and `SetTopLeft <#SetTopLeft>`_ .. attribute:: TopRight See `GetTopRight <#GetTopRight>`_ and `SetTopRight <#SetTopRight>`_ .. attribute:: Width See `GetWidth <#GetWidth>`_ and `SetWidth <#SetWidth>`_ .. attribute:: X See `GetX <#GetX>`_ and `SetX <#SetX>`_ .. attribute:: Y See `GetY <#GetY>`_ and `SetY <#SetY>`_ .. attribute:: bottom See `GetBottom <#GetBottom>`_ and `SetBottom <#SetBottom>`_ .. attribute:: height See `GetHeight <#GetHeight>`_ and `SetHeight <#SetHeight>`_ .. attribute:: left See `GetLeft <#GetLeft>`_ and `SetLeft <#SetLeft>`_ .. attribute:: position See `GetPosition <#GetPosition>`_ and `SetPosition <#SetPosition>`_ .. attribute:: right See `GetRight <#GetRight>`_ and `SetRight <#SetRight>`_ .. attribute:: size See `GetSize <#GetSize>`_ and `SetSize <#SetSize>`_ .. attribute:: top See `GetTop <#GetTop>`_ and `SetTop <#SetTop>`_ .. attribute:: width See `GetWidth <#GetWidth>`_ and `SetWidth <#SetWidth>`_ .. attribute:: x See `GetX <#GetX>`_ and `SetX <#SetX>`_ .. attribute:: y See `GetY <#GetY>`_ and `SetY <#SetY>`_