wx.Size¶A wx.Size is a useful data structure for graphics operations.
It simply contains integer x and y members.
Note that the width and height stored inside a wx.Size object may be negative and that wx.Size functions do not perform any check against negative values (this is used to e.g. store the special -1 value in wx.DefaultSize instance). See also IsFullySpecified and SetDefaults for utility functions regarding the special -1 value.
wx.Size is used throughout wxWidgets as well as wx.Point which, although almost equivalent to wx.Size, has a different meaning: wx.Point represents a position while wx.Size represents the size.
See also
Class Hierarchy¶
Inheritance diagram for class Size:

Methods Summary¶Initializes this size object with zero width and height. |
|
Decreases the size in both x and y directions. |
|
Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size. |
|
Decrements this object to be not bigger than the given size ignoring non-specified components. |
|
Return the width and height properties as a tuple. |
|
Gets the height member. |
|
Returns an immutable representation of the |
|
Gets the width member. |
|
Increases the size in both x and y directions. |
|
Increments this object so that both of its dimensions are not less than the corresponding dimensions of the size. |
|
Returns |
|
Scales the dimensions of this object by the given factors. |
|
Sets the width and height members. |
|
Combine this size object with another one replacing the default (i.e. equal to -1) components of this object with those of the other. |
|
Sets the height. |
|
Sets the width. |
|
Properties Summary¶
Class API¶wx.Size(object)¶Possible constructors:
Size()
Size(width, height)
A Size is a useful data structure for graphics operations.
__init__(self, *args, **kw)¶__init__ (self)
Initializes this size object with zero width and height.
__init__ (self, width, height)
Initializes this size object with the given width and height.
width (int) –
height (int) –
DecBy(self, *args, **kw)¶Decreases the size in both x and y directions.
DecTo(self, size)¶Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size.
size (wx.Size) –
See also
DecToIfSpecified(self, size)¶Decrements this object to be not bigger than the given size ignoring non-specified components.
This is similar to DecTo but doesn’t do anything for x or y component if the same component of size is not specified, i.e. set to wx.DefaultCoord .
size (wx.Size) –
New in version 2.9.5.
Get(self)¶Return the width and height properties as a tuple.
GetHeight(self)¶Gets the height member.
int
GetIM(self)¶Returns an immutable representation of the wx.Size object, based on namedtuple.
This new object is hashable and can be used as a dictionary key,
be added to sets, etc. It can be converted back into a real wx.Size
with a simple statement like this: obj = wx.Size(imObj).
GetWidth(self)¶Gets the width member.
int
IncBy(self, *args, **kw)¶Increases the size in both x and y directions.
IncTo(self, size)¶Increments this object so that both of its dimensions are not less than the corresponding dimensions of the size.
size (wx.Size) –
See also
IsFullySpecified(self)¶Returns True if neither of the size object components is equal to -1, which is used as default for the size values in wxWidgets (hence the predefined wx.DefaultSize has both of its components equal to -1).
This method is typically used before calling SetDefaults .
bool
Scale(self, xscale, yscale)¶Scales the dimensions of this object by the given factors.
If you want to scale both dimensions by the same factor you can also use operator*= .
xscale (float) –
yscale (float) –
A reference to this object (so that you can concatenate other operations in the same line).
Set(self, width, height)¶Sets the width and height members.
width (int) –
height (int) –
SetDefaults(self, sizeDefault)¶Combine this size object with another one replacing the default (i.e. equal to -1) components of this object with those of the other.
It is typically used like this:
if not size.IsFullySpecified():
size.SetDefaults(GetDefaultSize())
sizeDefault (wx.Size) –
See also
SetHeight(self, height)¶Sets the height.
height (int) –
SetWidth(self, width)¶Sets the width.
width (int) –
__bool__(self)¶__eq__(self, other)¶bool
__getitem__(self, idx)¶__len__(self)¶__ne__(self, other)¶bool
__nonzero__(self)¶__reduce__(self)¶__repr__(self)¶__setitem__(self, idx, val)¶__str__(self)¶__imul__(self)¶factor (int) –
__idiv__(self)¶factor (int) –