gtk.gdk.Rectangle — an object holding data about a rectangle
class gtk.gdk.Rectangle(gobject.GBoxed): |
|
A gtk.gdk.Rectangle
holds the position and size of a rectangle. The position is specified by the
"x" and "y" attributes and the size, by the "width" and "height"
attributes.
Starting with PyGTK 2.14 gtk.gdk.Rectangle
objects are
properly comparable. By Python rules, rectangles (being mutable) are now
unhashable. If you need to use them as dictionary keys, convert rectangle objects
to tuples first. You can convert such tuples back
to gtk.gdk.Rectangle
using the following code:
rectangle = gtk.gdk.Rectangle(*tuple)
Also beginning with PyGTK 2.14 gtk.gdk.Rectangle
objects have
custom support for repr
Python function. For any rectangle it
holds that:
rectangle == eval(repr(rectangle))
gtk.gdk.Rectangle(x
=0, y
=0, width
=0, height
=0)
| the X coordinate of the top left corner of the rectangle |
| the Y coordinate of the top left corner of the rectangle |
| the width of the rectangle |
| the height of the rectangle |
Returns : | a new gtk.gdk.Rectangle
object |
Creates a new gtk.gdk.Rectangle
with the attributes specified by x
,
y
, width
and
height
. Any unspecified attributes default to
0.
def intersect(src
)
| a gtk.gdk.Rectangle
of a 4-tuple specifying the attributes of a rectangle as (x, y, width,
height) |
Returns : | a gtk.gdk.Rectangle
that is the intersection of src and the
rectangle |
The intersect
() method returns a gtk.gdk.Rectangle
that is the intersection of this rectangle and the gtk.gdk.Rectangle
specified by src
. The value of
src
is either a gtk.gdk.Rectangle
or a 4-tuple containing the position and size of a rectangle. If the
rectangles do not intersect the returned gtk.gdk.Rectangle
will have all attributes set to 0.
def union(src
)
| a gtk.gdk.Rectangle
of a 4-tuple specifying the attributes of a rectangle as (x, y, width,
height) |
Returns : | a gtk.gdk.Rectangle
that includes both src and the
rectangle |
The union
() method returns a gtk.gdk.Rectangle
that is the smallest rectangle containing both this rectangle and the gtk.gdk.Rectangle
specified by src
. The value of
src
is either a gtk.gdk.Rectangle
or a 4-tuple containing the position and size of a rectangle.