.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.Size:
==========================================================================================================================================
|phoenix_title| **wx.Size**
==========================================================================================================================================
A :ref:`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 :ref:`wx.Size` object may be negative and that :ref:`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 :meth:`~wx.Size.IsFullySpecified` and :meth:`~wx.Size.SetDefaults` for utility functions regarding the special -1 value.
:ref:`wx.Size` is used throughout wxWidgets as well as :ref:`wx.Point` which, although almost equivalent to :ref:`wx.Size`, has a different meaning: :ref:`wx.Point` represents a position while :ref:`wx.Size` represents the size.
.. seealso:: :ref:`wx.Point`, :ref:`wx.RealPoint`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html

Inheritance diagram for class
Size:
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.Size.__init__` Initializes this size object with zero width and height.
:meth:`~wx.Size.DecBy` Decreases the size in both x and y directions.
:meth:`~wx.Size.DecTo` Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the `size`.
:meth:`~wx.Size.DecToIfSpecified` Decrements this object to be not bigger than the given size ignoring non-specified components.
:meth:`~wx.Size.Get` Return the width and height properties as a tuple.
:meth:`~wx.Size.GetHeight` Gets the height member.
:meth:`~wx.Size.GetIM` Returns an immutable representation of the ``wx.Size`` object, based on ``namedtuple``.
:meth:`~wx.Size.GetWidth` Gets the width member.
:meth:`~wx.Size.IncBy` Increases the size in both x and y directions.
:meth:`~wx.Size.IncTo` Increments this object so that both of its dimensions are not less than the corresponding dimensions of the `size`.
:meth:`~wx.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).
:meth:`~wx.Size.Scale` Scales the dimensions of this object by the given factors.
:meth:`~wx.Size.Set` Sets the width and height members.
:meth:`~wx.Size.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.
:meth:`~wx.Size.SetHeight` Sets the height.
:meth:`~wx.Size.SetWidth` Sets the width.
:meth:`~wx.Size.__bool__`
:meth:`~wx.Size.__eq__`
:meth:`~wx.Size.__getitem__`
:meth:`~wx.Size.__len__`
:meth:`~wx.Size.__ne__`
:meth:`~wx.Size.__nonzero__`
:meth:`~wx.Size.__reduce__`
:meth:`~wx.Size.__repr__`
:meth:`~wx.Size.__setitem__`
:meth:`~wx.Size.__str__`
:meth:`~wx.Size.__imul__`
:meth:`~wx.Size.__iadd__`
:meth:`~wx.Size.__isub__`
:meth:`~wx.Size.__idiv__`
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.Size.Height` See :meth:`~wx.Size.GetHeight` and :meth:`~wx.Size.SetHeight`
:attr:`~wx.Size.Width` See :meth:`~wx.Size.GetWidth` and :meth:`~wx.Size.SetWidth`
:attr:`~wx.Size.height` See :meth:`~wx.Size.GetHeight` and :meth:`~wx.Size.SetHeight`
:attr:`~wx.Size.width` See :meth:`~wx.Size.GetWidth` and :meth:`~wx.Size.SetWidth`
:attr:`~wx.Size.x` See :meth:`~wx.Size.GetWidth` and :meth:`~wx.Size.SetWidth`
:attr:`~wx.Size.y` See :meth:`~wx.Size.GetHeight` and :meth:`~wx.Size.SetHeight`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.Size(object)
**Possible constructors**::
Size() -> None
Size(width : int, height : int) -> None
A Size is a useful data structure for graphics operations.
.. method:: __init__(self, *args, **kw)
|overload| **Overloaded Implementations:**
:html:`
`
**__init__** `(self)`
Initializes this size object with zero width and height.
:rtype: `None`
:html:`
`
**__init__** `(self, width : int, height : int)`
Initializes this size object with the given `width` and `height`.
:param `width`:
:type `width`: int
:param `height`:
:type `height`: int
:rtype: `None`
:html:`
`
.. method:: DecBy(self, *args, **kw)
Decreases the size in both x and y directions.
.. seealso:: :meth:`IncBy`
|overload| **Overloaded Implementations:**
:html:`
`
**DecBy** `(self, pt : Point)`
:param `pt`:
:type `pt`: wx.Point
:rtype: `None`
:html:`
`
**DecBy** `(self, size : Size)`
:param `size`:
:type `size`: wx.Size
:rtype: `None`
:html:`
`
**DecBy** `(self, dx : int, dy : int)`
:param `dx`:
:type `dx`: int
:param `dy`:
:type `dy`: int
:rtype: `None`
:html:`
`
**DecBy** `(self, d : int)`
:param `d`:
:type `d`: int
:rtype: `None`
:html:`
`
.. method:: DecTo(self, size : Size)
Decrements this object so that both of its dimensions are not greater than the corresponding dimensions of the `size`.
:param `size`:
:type `size`: wx.Size
:rtype: `None`
.. seealso:: :meth:`IncTo`
.. method:: DecToIfSpecified(self, size : Size)
Decrements this object to be not bigger than the given size ignoring non-specified components.
This is similar to :meth:`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` .
:param `size`:
:type `size`: wx.Size
:rtype: `None`
.. versionadded:: 2.9.5
.. method:: Get(self)
Return the width and height properties as a tuple.
:rtype: `tuple`
:returns:
( `width`, `height` )
.. method:: GetHeight(self)
Gets the height member.
:rtype: `int`
.. method:: 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)``.
.. method:: GetWidth(self)
Gets the width member.
:rtype: `int`
.. method:: IncBy(self, *args, **kw)
Increases the size in both x and y directions.
.. seealso:: :meth:`DecBy`
|overload| **Overloaded Implementations:**
:html:`
`
**IncBy** `(self, pt : Point)`
:param `pt`:
:type `pt`: wx.Point
:rtype: `None`
:html:`
`
**IncBy** `(self, size : Size)`
:param `size`:
:type `size`: wx.Size
:rtype: `None`
:html:`
`
**IncBy** `(self, dx : int, dy : int)`
:param `dx`:
:type `dx`: int
:param `dy`:
:type `dy`: int
:rtype: `None`
:html:`
`
**IncBy** `(self, d : int)`
:param `d`:
:type `d`: int
:rtype: `None`
:html:`
`
.. method:: IncTo(self, size : Size)
Increments this object so that both of its dimensions are not less than the corresponding dimensions of the `size`.
:param `size`:
:type `size`: wx.Size
:rtype: `None`
.. seealso:: :meth:`DecTo`
.. method:: 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 :meth:`SetDefaults` .
:rtype: `bool`
.. method:: Scale(self, xscale : float, yscale : float)
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 :meth:`operator*=` .
:param `xscale`:
:type `xscale`: float
:param `yscale`:
:type `yscale`: float
:rtype: :ref:`wx.Size`
:returns:
A reference to this object (so that you can concatenate other operations in the same line).
.. method:: Set(self, width : int, height : int)
Sets the width and height members.
:param `width`:
:type `width`: int
:param `height`:
:type `height`: int
:rtype: `None`
.. method:: SetDefaults(self, sizeDefault : Size)
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())
:param `sizeDefault`:
:type `sizeDefault`: wx.Size
:rtype: `None`
.. seealso:: :meth:`IsFullySpecified`
.. method:: SetHeight(self, height : int)
Sets the height.
:param `height`:
:type `height`: int
:rtype: `None`
.. method:: SetWidth(self, width : int)
Sets the width.
:param `width`:
:type `width`: int
:rtype: `None`
.. method:: __bool__(self)
.. method:: __eq__(self, other: Size)
:rtype: `bool`
.. method:: __getitem__(self, idx)
.. method:: __len__(self)
.. method:: __ne__(self, other: Size)
:rtype: `bool`
.. method:: __nonzero__(self)
.. method:: __reduce__(self)
.. method:: __repr__(self)
.. method:: __setitem__(self, idx, val)
.. method:: __str__(self)
.. method:: __imul__(self)
:param `factor`:
:type `factor`: int
.. method:: __iadd__(self)
:param `sz`:
:type `sz`: wx.Size
.. method:: __isub__(self)
:param `sz`:
:type `sz`: wx.Size
.. method:: __idiv__(self)
:param `factor`:
:type `factor`: int
.. attribute:: Height
See :meth:`~wx.Size.GetHeight` and :meth:`~wx.Size.SetHeight`
.. attribute:: Width
See :meth:`~wx.Size.GetWidth` and :meth:`~wx.Size.SetWidth`
.. attribute:: height
See :meth:`~wx.Size.GetHeight` and :meth:`~wx.Size.SetHeight`
.. attribute:: width
See :meth:`~wx.Size.GetWidth` and :meth:`~wx.Size.SetWidth`
.. attribute:: x
See :meth:`~wx.Size.GetWidth` and :meth:`~wx.Size.SetWidth`
.. attribute:: y
See :meth:`~wx.Size.GetHeight` and :meth:`~wx.Size.SetHeight`