Phoenix Logo

phoenix_title wx.Size

A wx.Size is a useful data structure for graphics operations.

It simply contains integer width and height 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.


class_hierarchy Class Hierarchy

Inheritance diagram for class Size:

method_summary Methods Summary

__init__ Initializes this size object with zero width and height.
DecBy Decreases the size in both x and y directions.
DecTo Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the size.
DecToIfSpecified Decrements this object to be not bigger than the given size ignoring non-specified components.
Get Return the width and height properties as a tuple.
GetHeight Gets the height member.
GetIM Returns an immutable representation of the wx.Size object, based on namedtuple.
GetWidth Gets the width member.
IncBy Increases the size in both x and y directions.
IncTo Increments this object so that both of its dimensions are not less than the corresponding dimensions of the size.
IsFullySpecified 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).
Scale Scales the dimensions of this object by the given factors.
Set Sets the width and height members.
SetDefaults Combine this size object with another one replacing the default (i.e. equal to -1) components of this object with those of the other.
SetHeight Sets the height.
SetWidth Sets the width.
__eq__  
__getitem__  
__len__  
__ne__  
__nonzero__  
__reduce__  
__repr__  
__setitem__  
__str__  
__imul__  
__iadd__  
__isub__  
__idiv__  

property_summary Properties Summary

Height See GetHeight and SetHeight
Width See GetWidth and SetWidth
height See GetHeight and SetHeight
width See GetWidth and SetWidth
x See GetWidth and SetWidth
y See GetHeight and SetHeight

api Class API



class wx.Size(object)

Possible constructors:

Size()

Size(width, height)

A Size is a useful data structure for graphics operations.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__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.

Parameters:
  • width (int) –
  • height (int) –





DecBy(self, *args, **kw)

Decreases the size in both x and y directions.

See also

IncBy

overload Overloaded Implementations:



DecBy (self, pt)

Parameters:pt (wx.Point) –



DecBy (self, size)

Parameters:size (wx.Size) –



DecBy (self, dx, dy)

Parameters:
  • dx (int) –
  • dy (int) –



DecBy (self, d)

Parameters:d (int) –





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) –

See also

IncTo



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 .

Parameters:size (wx.Size) –

New in version 2.9.5.



Get(self)

Return the width and height properties as a tuple.

Return type:tuple
Returns:( width, height )


GetHeight(self)

Gets the height member.

Return type: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.

Return type:int


IncBy(self, *args, **kw)

Increases the size in both x and y directions.

See also

DecBy

overload Overloaded Implementations:



IncBy (self, pt)

Parameters:pt (wx.Point) –



IncBy (self, size)

Parameters:size (wx.Size) –



IncBy (self, dx, dy)

Parameters:
  • dx (int) –
  • dy (int) –



IncBy (self, d)

Parameters:d (int) –





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) –

See also

DecTo



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 .

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:

wx.Size

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) –


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) –

See also

IsFullySpecified



SetHeight(self, height)

Sets the height.

Parameters:height (int) –


SetWidth(self, width)

Sets the width.

Parameters:width (int) –


__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)


__imul__(self)
Parameters:factor (int) –


__iadd__(self)
Parameters:sz (wx.Size) –


__isub__(self)
Parameters:sz (wx.Size) –


__idiv__(self)
Parameters:factor (int) –

Properties



Height

See GetHeight and SetHeight



Width

See GetWidth and SetWidth



height

See GetHeight and SetHeight



width

See GetWidth and SetWidth



x

See GetWidth and SetWidth



y

See GetHeight and SetHeight