.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2017 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 `width`  and `height`  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 :ref:`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

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>Size</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.Size_inheritance.png" alt="Inheritance diagram of Size" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Size.html" title="wx.Size" alt="" coords="5,5,77,35"/> </map> 
   </p>

|


|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 :ref:`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.__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()
       
       Size(width, height)
       
   
   A Size is a useful data structure for graphics operations.



   .. method:: __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`.                  
      
      
      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int
      
      
      
      
      
      
      **~~~**






   .. method:: DecBy(self, *args, **kw)

      Decreases the size in both x and y directions.                  

                 



      .. seealso:: :meth:`IncBy`     





      |overload| Overloaded Implementations:

      **~~~**

      
      **DecBy** `(self, pt)`
      
      
      
      
      :param `pt`: 
      :type `pt`: wx.Point
      
      
      
      
      
      
      **~~~**

      
      **DecBy** `(self, size)`
      
      
      
      
      :param `size`: 
      :type `size`: wx.Size
      
      
      
      
      
      
      **~~~**

      
      **DecBy** `(self, dx, dy)`
      
      
      
      
      :param `dx`: 
      :type `dx`: int
      :param `dy`: 
      :type `dy`: int
      
      
      
      
      
      
      **~~~**

      
      **DecBy** `(self, d)`
      
      
      
      
      :param `d`: 
      :type `d`: int
      
      
      
      
      
      
      **~~~**






   .. method:: DecTo(self, 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






      .. seealso:: :meth:`IncTo`     








   .. method:: DecToIfSpecified(self, 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 :ref:`wx.DefaultCoord`. 

                


      :param `size`: 
      :type `size`: wx.Size






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

      **~~~**

      
      **IncBy** `(self, pt)`
      
      
      
      
      :param `pt`: 
      :type `pt`: wx.Point
      
      
      
      
      
      
      **~~~**

      
      **IncBy** `(self, size)`
      
      
      
      
      :param `size`: 
      :type `size`: wx.Size
      
      
      
      
      
      
      **~~~**

      
      **IncBy** `(self, dx, dy)`
      
      
      
      
      :param `dx`: 
      :type `dx`: int
      :param `dy`: 
      :type `dy`: int
      
      
      
      
      
      
      **~~~**

      
      **IncBy** `(self, d)`
      
      
      
      
      :param `d`: 
      :type `d`: int
      
      
      
      
      
      
      **~~~**






   .. method:: IncTo(self, 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






      .. 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 :ref:`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, 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 :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, height)

      Sets the width and height members.                  


      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int







   .. method:: 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())



                


      :param `sizeDefault`: 
      :type `sizeDefault`: wx.Size






      .. seealso:: :meth:`IsFullySpecified`     








   .. method:: SetHeight(self, height)

      Sets the height.                  


      :param `height`: 
      :type `height`: int







   .. method:: SetWidth(self, width)

      Sets the width.                  


      :param `width`: 
      :type `width`: int







   .. method:: __eq__(self, other)



      :rtype: `bool`








   .. method:: __getitem__(self, idx)




   .. method:: __len__(self)




   .. method:: __ne__(self, other)



      :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`

