Package wx :: Class Rect

[frames | no frames]

## Type Rect

    object --+
             |
            Rect

A class for representing and manipulating rectangles. It has x, y, width and height properties. In wxPython most palces that expect a wx.Rect can also accept a (x,y,width,height) tuple.

Method Summary
Rect | ``__init__`(self, x, y, width, height)` Create a new Rect object.
Rect | ``__add__`(self, rect)` Add the properties of rect to this rectangle and return the result.
| `__del__(self)`
bool | ``__eq__`(self, other)` Test for equality of wx.Rect objects.
| `__getitem__(self, index)`
Rect | ``__iadd__`(self, rect)` Add the properties of rect to this rectangle, updating this rectangle.
| `__len__(self)`
bool | ``__ne__`(self, other)` Test for inequality of wx.Rect objects.
| `__nonzero__(self)`
| `__reduce__(self)`
| `__repr__(self)`
| `__setitem__(self, index, val)`
| `__str__(self)`
| ``asTuple`(*args, **kwargs)` asTuple is deprecated, use `Get` instead
Rect | ``CenterIn`(self, r, dir)` Center this rectangle within the one passed to the method, which is usually, but not necessarily, the larger one.
Rect | ``CentreIn`(self, r, dir)` Center this rectangle within the one passed to the method, which is usually, but not necessarily, the larger one.
bool | ``Contains`(self, pt)` Return True if the point is inside the rect.
bool | ``ContainsRect`(self, rect)` Returns `True` if the given rectangle is completely inside this rectangle or touches its boundary.
bool | ``ContainsXY`(self, x, y)` Return True if the point is inside the rect.
Rect | ``Deflate`(self, dx, dy)` Decrease the rectangle size.
(x,y,width,height) | ``Get`()` Return the rectangle properties as a tuple.
int | `GetBottom(self)`
Point | `GetBottomLeft(self)`
Point | `GetBottomRight(self)`
int | `GetHeight(self)`
int | `GetLeft(self)`
Point | `GetPosition(self)`
int | `GetRight(self)`
Size | `GetSize(self)`
int | `GetTop(self)`
Point | `GetTopLeft(self)`
Point | `GetTopRight(self)`
int | `GetWidth(self)`
int | `GetX(self)`
int | `GetY(self)`
Rect | ``Inflate`(self, dx, dy)` Increases the size of the rectangle.
bool | ``Inside`(self, pt)` Return True if the point is inside the rect.
bool | ``InsideRect`(self, rect)` Returns `True` if the given rectangle is completely inside this rectangle or touches its boundary.
bool | ``InsideXY`(self, x, y)` Return True if the point is inside the rect.
Rect | ``Intersect`(self, rect)` Returns the intersectsion of this rectangle and rect.
bool | ``Intersects`(self, rect)` Returns True if the rectangles have a non empty intersection.
bool | `IsEmpty(self)`
| ``Offset`(self, pt)` Same as `OffsetXY` but uses dx,dy from Point
| ``OffsetXY`(self, dx, dy)` Moves the rectangle by the specified offset.
| ``Set`(self, x, y, width, height)` Set all rectangle properties.
| `SetBottom(self, bottom)`
| `SetBottomLeft(self, p)`
| `SetBottomRight(self, p)`
| `SetHeight(self, h)`
| `SetLeft(self, left)`
| `SetPosition(self, p)`
| `SetRight(self, right)`
| `SetSize(self, s)`
| `SetTop(self, top)`
| `SetTopLeft(self, p)`
| `SetTopRight(self, p)`
| `SetWidth(self, w)`
| `SetX(self, x)`
| `SetY(self, y)`
Rect | ``Union`(self, rect)` Returns the union of this rectangle and rect.

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

Class Variable Summary
`bool` | `__safe_for_unpickling__` = `True`

Method Details

### __init__(self, x=0, y=0, width=0, height=0)
(Constructor)

Create a new Rect object.

  Parameters:
    `x`
    (type=int)

    `y`
    (type=int)

    `width`
    (type=int)

    `height`
    (type=int)

  Returns:
    Rect
  Overrides:
    `__builtin__.object.__init__`

### __add__(self, rect)
(Addition operator)

Add the properties of rect to this rectangle and return the result.

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    Rect

### __eq__(self, other)
(Equality operator)

Test for equality of wx.Rect objects.

  Parameters:
    `other`
    (type=PyObject)

  Returns:
    bool

### __iadd__(self, rect)

Add the properties of rect to this rectangle, updating this rectangle.

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    Rect

### __ne__(self, other)

Test for inequality of wx.Rect objects.

  Parameters:
    `other`
    (type=PyObject)

  Returns:
    bool

### asTuple(*args, **kwargs)

asTuple is deprecated, use `Get` instead

### CenterIn(self, r, dir=BOTH)

Center this rectangle within the one passed to the method, which is usually, but not necessarily, the larger one.

  Parameters:
    `r`
    (type=Rect)

    `dir`
    (type=int)

  Returns:
    Rect

### CentreIn(self, r, dir=BOTH)

Center this rectangle within the one passed to the method, which is usually, but not necessarily, the larger one.

  Parameters:
    `r`
    (type=Rect)

    `dir`
    (type=int)

  Returns:
    Rect

### Contains(self, pt)

Return True if the point is inside the rect.

  Parameters:
    `pt`
    (type=Point)

  Returns:
    bool

### ContainsRect(self, rect)

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

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    bool

### ContainsXY(self, x, y)

Return True if the point is inside the rect.

  Parameters:
    `x`
    (type=int)

    `y`
    (type=int)

  Returns:
    bool

### Deflate(self, dx, dy)

Decrease the rectangle size. This method is the opposite of `Inflate` in that Deflate(a,b) is equivalent to Inflate(-a,-b). Please refer to `Inflate` for a full description.

  Parameters:
    `dx`
    (type=int)

    `dy`
    (type=int)

  Returns:
    Rect

### Get()

Return the rectangle properties as a tuple.

  Returns:
    (x,y,width,height)

### Inflate(self, 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)

Inflating and deflating behaves naturally. Defined more precisely, that means:

> - Real inflates (that is, `dx` and/or `dy` >= 0) are not constrained. Thus inflating a rectangle can cause its upper left corner to move into the negative numbers. (The versions prior to 2.5.4 forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.)
> - Deflates are clamped to not reduce the width or height of the rectangle below zero. In such cases, the top-left corner is nonetheless handled properly. For example, a rectangle at (10, 10) with size (20, 40) that is inflated by (-15, -15) will become located at (20, 25) at size (0, 10). Finally, observe that the width and height are treated independently. In the above example, the width is reduced by 20, whereas the height is reduced by the full 30 (rather than also stopping at 20, when the width reached zero).

  Parameters:
    `dx`
    (type=int)

    `dy`
    (type=int)

  Returns:
    Rect

  See Also:

  `Deflate`

### Inside(self, pt)

Return True if the point is inside the rect.

  Parameters:
    `pt`
    (type=Point)

  Returns:
    bool

### InsideRect(self, rect)

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

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    bool

### InsideXY(self, x, y)

Return True if the point is inside the rect.

  Parameters:
    `x`
    (type=int)

    `y`
    (type=int)

  Returns:
    bool

### Intersect(self, rect)

Returns the intersectsion of this rectangle and rect.

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    Rect

### Intersects(self, rect)

Returns True if the rectangles have a non empty intersection.

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    bool

### Offset(self, pt)

Same as `OffsetXY` but uses dx,dy from Point

  Parameters:
    `pt`
    (type=Point)

### OffsetXY(self, 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`
    (type=int)

    `dy`
    (type=int)

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

Set all rectangle properties.

  Parameters:
    `x`
    (type=int)

    `y`
    (type=int)

    `width`
    (type=int)

    `height`
    (type=int)

### Union(self, rect)

Returns the union of this rectangle and rect.

  Parameters:
    `rect`
    (type=Rect)

  Returns:
    Rect

Property Details

### Bottom

See `GetBottom` and `SetBottom`

  Get Method:
    `GetBottom`(self)
  Set Method:
    `SetBottom`(self, bottom)

### bottom

  Get Method:
    `GetBottom`(self)
  Set Method:
    `SetBottom`(self, bottom)

### BottomLeft

See `GetBottomLeft` and `SetBottomLeft`

  Get Method:
    `GetBottomLeft`(self)
  Set Method:
    `SetBottomLeft`(self, p)

### BottomRight

See `GetBottomRight` and `SetBottomRight`

  Get Method:
    `GetBottomRight`(self)
  Set Method:
    `SetBottomRight`(self, p)

### Empty

See `IsEmpty`

  Get Method:
    `IsEmpty`(self)

### Height

See `GetHeight` and `SetHeight`

  Get Method:
    `GetHeight`(self)
  Set Method:
    `SetHeight`(self, h)

### Left

See `GetLeft` and `SetLeft`

  Get Method:
    `GetLeft`(self)
  Set Method:
    `SetLeft`(self, left)

### left

  Get Method:
    `GetLeft`(self)
  Set Method:
    `SetLeft`(self, left)

### Position

See `GetPosition` and `SetPosition`

  Get Method:
    `GetPosition`(self)
  Set Method:
    `SetPosition`(self, p)

### position

  Get Method:
    `GetPosition`(self)
  Set Method:
    `SetPosition`(self, p)

### Right

See `GetRight` and `SetRight`

  Get Method:
    `GetRight`(self)
  Set Method:
    `SetRight`(self, right)

### right

  Get Method:
    `GetRight`(self)
  Set Method:
    `SetRight`(self, right)

### Size

See `GetSize` and `SetSize`

  Get Method:
    `GetSize`(self)
  Set Method:
    `SetSize`(self, s)

### size

  Get Method:
    `GetSize`(self)
  Set Method:
    `SetSize`(self, s)

### thisown

The membership flag

### Top

See `GetTop` and `SetTop`

  Get Method:
    `GetTop`(self)
  Set Method:
    `SetTop`(self, top)

### top

  Get Method:
    `GetTop`(self)
  Set Method:
    `SetTop`(self, top)

### TopLeft

See `GetTopLeft` and `SetTopLeft`

  Get Method:
    `GetTopLeft`(self)
  Set Method:
    `SetTopLeft`(self, p)

### TopRight

See `GetTopRight` and `SetTopRight`

  Get Method:
    `GetTopRight`(self)
  Set Method:
    `SetTopRight`(self, p)

### Width

See `GetWidth` and `SetWidth`

  Get Method:
    `GetWidth`(self)
  Set Method:
    `SetWidth`(self, w)

### X

See `GetX` and `SetX`

  Get Method:
    `GetX`(self)
  Set Method:
    `SetX`(self, x)

### Y

See `GetY` and `SetY`

  Get Method:
    `GetY`(self)
  Set Method:
    `SetY`(self, y)

Class Variable Details

### __safe_for_unpickling__

  Type:
    `bool`
  Value:

        True

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:09:48 2007 | http://epydoc.sf.net