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¶
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¶
- class wx.Size(object)¶
Possible constructors:
Size() -> None Size(width, height) -> None
A Size is a useful data structure for graphics operations.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Initializes this size object with zero width and height.
- Return type:
None
__init__ (self, width, height)
Initializes this size object with the given
width
andheight
.- Parameters:
width (int)
height (int)
- Return type:
None
- DecBy(self, *args, **kw)¶
Decreases the size in both x and y directions.
See also
DecBy (self, pt)
- Parameters:
pt (wx.Point)
- Return type:
None
DecBy (self, size)
- Parameters:
size (wx.Size)
- Return type:
None
DecBy (self, dx, dy)
- Parameters:
dx (int)
dy (int)
- Return type:
None
DecBy (self, d)
- Parameters:
d (int)
- Return type:
None
- DecTo(self, size)¶
Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size.
- Parameters:
size (wx.Size)
- Return type:
None
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 towx.DefaultCoord
.- Parameters:
size (wx.Size)
- Return type:
None
Added in version 2.9.5.
- Get(self)¶
Return the width and height properties as a tuple.
- Return type:
Any
- GetHeight(self)¶
Gets the height member.
- Return type:
int
- GetIM(self)¶
Returns an immutable representation of the
wx.Size
object, based onnamedtuple
.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.
- Return type:
int
- IncBy(self, *args, **kw)¶
Increases the size in both x and y directions.
See also
IncBy (self, pt)
- Parameters:
pt (wx.Point)
- Return type:
None
IncBy (self, size)
- Parameters:
size (wx.Size)
- Return type:
None
IncBy (self, dx, dy)
- Parameters:
dx (int)
dy (int)
- Return type:
None
IncBy (self, d)
- Parameters:
d (int)
- Return type:
None
- IncTo(self, size)¶
Increments this object so that both of its dimensions are not less than the corresponding dimensions of the size.
- Parameters:
size (wx.Size)
- Return type:
None
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 predefinedwx.DefaultSize
has both of its components equal to -1).This method is typically used before calling
SetDefaults
.- Return type:
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*=
.- Parameters:
xscale (float)
yscale (float)
- Return type:
- Returns:
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.
- Parameters:
width (int)
height (int)
- Return type:
None
- 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())
- Parameters:
sizeDefault (wx.Size)
- Return type:
None
See also
- SetHeight(self, height)¶
Sets the height.
- Parameters:
height (int)
- Return type:
None
- SetWidth(self, width)¶
Sets the width.
- Parameters:
width (int)
- Return type:
None
- __bool__(self)¶
- __eq__(self, other)¶
- Return type:
bool
- __getitem__(self, idx)¶
- __len__(self)¶
- __ne__(self, other)¶
- Return type:
bool
- __nonzero__(self)¶
- __reduce__(self)¶
- __repr__(self)¶
- __setitem__(self, idx, val)¶
- __str__(self)¶
Properties¶