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

==========================================================================================================================================
|phoenix_title|  **wx.SizerItem**
==========================================================================================================================================

The :ref:`wx.SizerItem`  class is used to track the position, size and other attributes of each item managed by a :ref:`wx.Sizer`.          

It is not usually necessary to use this class because the sizer elements can also be identified by their positions or window or sizer pointers but sometimes it may be more convenient to use it directly. 









|

|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>SizerItem</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.SizerItem_inheritance.png" alt="Inheritance diagram of SizerItem" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.SizerItem.html" title="wx.SizerItem" alt="" coords="5,83,112,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="15,5,102,35"/> </map> 
   </p>
   </div>

|


|sub_classes| Known Subclasses
==============================

:ref:`wx.GBSizerItem`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.SizerItem.__init__`                                                   Construct a sizer item for tracking a window.
:meth:`~wx.SizerItem.AssignSizer`                                                Set the sizer tracked by this item.
:meth:`~wx.SizerItem.AssignSpacer`                                               Set the size of the spacer tracked by this item.
:meth:`~wx.SizerItem.AssignWindow`                                               Set the window to be tracked by this item.
:meth:`~wx.SizerItem.CalcMin`                                                    Calculates the minimum desired size for the item, including any space needed by borders.
:meth:`~wx.SizerItem.DeleteWindows`                                              Destroy the window or the windows in a subsizer, depending on the type of item.
:meth:`~wx.SizerItem.DetachSizer`                                                Enable deleting the SizerItem without destroying the contained sizer.
:meth:`~wx.SizerItem.GetBorder`                                                  Return the border attribute.
:meth:`~wx.SizerItem.GetFlag`                                                    Return the flags attribute.
:meth:`~wx.SizerItem.GetId`                                                      Return the numeric id of :ref:`wx.SizerItem`, or  ``ID_NONE``   if the id has not been set.
:meth:`~wx.SizerItem.GetMinSize`                                                 Get the minimum size needed for the item.
:meth:`~wx.SizerItem.GetPosition`                                                What is the current position of the item, as set in the last Layout.
:meth:`~wx.SizerItem.GetProportion`                                              Get the proportion item attribute.
:meth:`~wx.SizerItem.GetRatio`                                                   Get the ratio item attribute.
:meth:`~wx.SizerItem.GetRect`                                                    Get the rectangle of the item on the parent window, excluding borders.
:meth:`~wx.SizerItem.GetSize`                                                    Get the current size of the item, as set in the last Layout.
:meth:`~wx.SizerItem.GetSizer`                                                   If this item is tracking a sizer, return it.
:meth:`~wx.SizerItem.GetSpacer`                                                  If this item is tracking a spacer, return its size.
:meth:`~wx.SizerItem.GetUserData`                                                Get the userData item attribute.
:meth:`~wx.SizerItem.GetWindow`                                                  If this item is tracking a window then return it.
:meth:`~wx.SizerItem.IsShown`                                                    Returns ``True`` if this item is a window or a spacer and it is shown or if this item is a sizer and not all of its elements are hidden.
:meth:`~wx.SizerItem.IsSizer`                                                    Is this item a sizer?
:meth:`~wx.SizerItem.IsSpacer`                                                   Is this item a spacer?
:meth:`~wx.SizerItem.IsWindow`                                                   Is this item a window?
:meth:`~wx.SizerItem.SetBorder`                                                  Set the border item attribute.
:meth:`~wx.SizerItem.SetDimension`                                               Set the position and size of the space allocated to the sizer, and adjust the position and size of the item to be within that space taking alignment and borders into account.
:meth:`~wx.SizerItem.SetFlag`                                                    Set the flag item attribute.
:meth:`~wx.SizerItem.SetId`                                                      Sets the numeric id of the :ref:`wx.SizerItem`  to `id`.
:meth:`~wx.SizerItem.SetInitSize`                                                Sets the minimum size to be allocated for this item.
:meth:`~wx.SizerItem.SetMinSize`                                                 Sets the minimum size to be allocated for this item.
:meth:`~wx.SizerItem.SetProportion`                                              Set the proportion item attribute.
:meth:`~wx.SizerItem.SetRatio`                                                   Set the ratio item attribute.
:meth:`~wx.SizerItem.SetUserData`                                                
:meth:`~wx.SizerItem.Show`                                                       Set the show item attribute, which sizers use to determine if the item is to be made part of the layout or not.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.SizerItem.Border`                                                     See :meth:`~wx.SizerItem.GetBorder` and :meth:`~wx.SizerItem.SetBorder`
:attr:`~wx.SizerItem.Flag`                                                       See :meth:`~wx.SizerItem.GetFlag` and :meth:`~wx.SizerItem.SetFlag`
:attr:`~wx.SizerItem.Id`                                                         See :meth:`~wx.SizerItem.GetId` and :meth:`~wx.SizerItem.SetId`
:attr:`~wx.SizerItem.MinSize`                                                    See :meth:`~wx.SizerItem.GetMinSize` and :meth:`~wx.SizerItem.SetMinSize`
:attr:`~wx.SizerItem.Position`                                                   See :meth:`~wx.SizerItem.GetPosition`
:attr:`~wx.SizerItem.Proportion`                                                 See :meth:`~wx.SizerItem.GetProportion` and :meth:`~wx.SizerItem.SetProportion`
:attr:`~wx.SizerItem.Ratio`                                                      See :meth:`~wx.SizerItem.GetRatio` and :meth:`~wx.SizerItem.SetRatio`
:attr:`~wx.SizerItem.Rect`                                                       See :meth:`~wx.SizerItem.GetRect`
:attr:`~wx.SizerItem.Size`                                                       See :meth:`~wx.SizerItem.GetSize`
:attr:`~wx.SizerItem.Sizer`                                                      See :meth:`~wx.SizerItem.GetSizer`
:attr:`~wx.SizerItem.Spacer`                                                     See :meth:`~wx.SizerItem.GetSpacer`
:attr:`~wx.SizerItem.UserData`                                                   See :meth:`~wx.SizerItem.GetUserData` and :meth:`~wx.SizerItem.SetUserData`
:attr:`~wx.SizerItem.Window`                                                     See :meth:`~wx.SizerItem.GetWindow`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.SizerItem(Object)

   **Possible constructors**::

       SizerItem(window, flags)
       
       SizerItem(window, proportion=0, flag=0, border=0, userData=None)
       
       SizerItem(sizer, flags)
       
       SizerItem(sizer, proportion=0, flag=0, border=0, userData=None)
       
       SizerItem(width, height, proportion=0, flag=0, border=0, userData=None)
       
   
   The SizerItem class is used to track the position, size and other
   attributes of each item managed by a Sizer.



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



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, window, flags)`
      
      Construct a sizer item for tracking a window.                  
      
      
      :param `window`: 
      :type `window`: wx.Window
      :param `flags`: 
      :type `flags`: wx.SizerFlags
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, window, proportion=0, flag=0, border=0, userData=None)`
      
      Construct a sizer item for tracking a window.                  
      
      
      :param `window`: 
      :type `window`: wx.Window
      :param `proportion`: 
      :type `proportion`: int
      :param `flag`: 
      :type `flag`: int
      :param `border`: 
      :type `border`: int
      :param `userData`: 
      :type `userData`: PyUserData
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, sizer, flags)`
      
      Construct a sizer item for tracking a subsizer.                  
      
      
      :param `sizer`: 
      :type `sizer`: wx.Sizer
      :param `flags`: 
      :type `flags`: wx.SizerFlags
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, sizer, proportion=0, flag=0, border=0, userData=None)`
      
      Construct a sizer item for tracking a subsizer.                  
      
      
      :param `sizer`: 
      :type `sizer`: wx.Sizer
      :param `proportion`: 
      :type `proportion`: int
      :param `flag`: 
      :type `flag`: int
      :param `border`: 
      :type `border`: int
      :param `userData`: 
      :type `userData`: PyUserData
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, width, height, proportion=0, flag=0, border=0, userData=None)`
      
      Construct a sizer item for tracking a spacer.                  
      
      
      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int
      :param `proportion`: 
      :type `proportion`: int
      :param `flag`: 
      :type `flag`: int
      :param `border`: 
      :type `border`: int
      :param `userData`: 
      :type `userData`: PyUserData
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: AssignSizer(self, sizer)

      Set the sizer tracked by this item.                  

      Old sizer, if any, is deleted.                  


      :param `sizer`: 
      :type `sizer`: wx.Sizer







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

      Set the size of the spacer tracked by this item.                  

      Old spacer, if any, is deleted.                   


      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **AssignSpacer** `(self, size)`
      
      
      
      
      :param `size`: 
      :type `size`: wx.Size
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **AssignSpacer** `(self, w, h)`
      
      
      
      
      :param `w`: 
      :type `w`: int
      :param `h`: 
      :type `h`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: AssignWindow(self, window)

      Set the window to be tracked by this item.                  


      If the sizer item previously contained a window, it is dissociated from the sizer containing this sizer item (if any), but this object doesn't have the pointer to the containing sizer and so it's the caller's responsibility to call  :meth:`wx.Window.SetContainingSizer`   on `window`. Failure to do this can result in memory corruption when the window is destroyed later, so it is crucial to not forget to do it. 

      Also note that the previously contained window is `not`  deleted, so it's also the callers responsibility to do it, if necessary.                  


      :param `window`: 
      :type `window`: wx.Window






      .. note:: 

         This is a low-level method which is dangerous if used incorrectly, avoid using it if possible, i.e. if higher level methods such as :meth:`wx.Sizer.Replace`   can be used instead.  








   .. method:: CalcMin(self)

      Calculates the minimum desired size for the item, including any space needed by borders.                  

      :rtype: :ref:`wx.Size`








   .. method:: DeleteWindows(self)

      Destroy the window or the windows in a subsizer, depending on the type of item.                   





   .. method:: DetachSizer(self)

      Enable deleting the SizerItem without destroying the contained sizer.                   





   .. method:: GetBorder(self)

      Return the border attribute.                  

      :rtype: `int`








   .. method:: GetFlag(self)

      Return the flags attribute.                  

      See :ref:`Sizer flags list <wx.Sizer>`  for details.                  

      :rtype: `int`








   .. method:: GetId(self)

      Return the numeric id of :ref:`wx.SizerItem`, or  ``ID_NONE``   if the id has not been set.                   

      :rtype: `int`








   .. method:: GetMinSize(self)

      Get the minimum size needed for the item.                  

      :rtype: :ref:`wx.Size`








   .. method:: GetPosition(self)

      What is the current position of the item, as set in the last Layout.                  

      :rtype: :ref:`wx.Point`








   .. method:: GetProportion(self)

      Get the proportion item attribute.                  

      :rtype: `int`








   .. method:: GetRatio(self)

      Get the ratio item attribute.                  

      :rtype: `float`








   .. method:: GetRect(self)

      Get the rectangle of the item on the parent window, excluding borders.                  

      :rtype: :ref:`wx.Rect`








   .. method:: GetSize(self)

      Get the current size of the item, as set in the last Layout.                  

      :rtype: :ref:`wx.Size`








   .. method:: GetSizer(self)

      If this item is tracking a sizer, return it.                  

      ``None`` otherwise.                  

      :rtype: :ref:`wx.Sizer`








   .. method:: GetSpacer(self)

      If this item is tracking a spacer, return its size.                  

      :rtype: :ref:`wx.Size`








   .. method:: GetUserData(self)

      Get the userData item attribute.                  

      :rtype: :ref:`PyUserData`








   .. method:: GetWindow(self)

      If this item is tracking a window then return it.                  

      ``None`` otherwise.                  

      :rtype: :ref:`wx.Window`








   .. method:: IsShown(self)

      Returns ``True`` if this item is a window or a spacer and it is shown or if this item is a sizer and not all of its elements are hidden.                  

      In other words, for sizer items, all of the child elements must be hidden for the sizer itself to be considered hidden. 

      As an exception, if the  ``RESERVE_SPACE_EVEN_IF_HIDDEN``   flag was used for this sizer item, then  :meth:`IsShown`   always returns ``True`` for it (see :meth:`wx.SizerFlags.ReserveSpaceEvenIfHidden` ).                  

      :rtype: `bool`








   .. method:: IsSizer(self)

      Is this item a sizer?                  

      :rtype: `bool`








   .. method:: IsSpacer(self)

      Is this item a spacer?                  

      :rtype: `bool`








   .. method:: IsWindow(self)

      Is this item a window?                  

      :rtype: `bool`








   .. method:: SetBorder(self, border)

      Set the border item attribute.                  


      :param `border`: 
      :type `border`: int







   .. method:: SetDimension(self, pos, size)

      Set the position and size of the space allocated to the sizer, and adjust the position and size of the item to be within that space taking alignment and borders into account.                  


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







   .. method:: SetFlag(self, flag)

      Set the flag item attribute.                  


      :param `flag`: 
      :type `flag`: int







   .. method:: SetId(self, id)

      Sets the numeric id of the :ref:`wx.SizerItem`  to `id`.                  


      :param `id`: 
      :type `id`: int







   .. method:: SetInitSize(self, x, y)

      Sets the minimum size to be allocated for this item.                  

      This is identical to :meth:`SetMinSize` , prefer to use the other function, as its name is more clear.                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int







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



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetMinSize** `(self, size)`
      
      Sets the minimum size to be allocated for this item.                  
      
      If this item is a window, the `size`  is also passed to :meth:`wx.Window.SetMinSize` .                  
      
      
      :param `size`: 
      :type `size`: wx.Size
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetMinSize** `(self, x, y)`
      
      This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.                  
      
      
      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetProportion(self, proportion)

      Set the proportion item attribute.                  


      :param `proportion`: 
      :type `proportion`: int







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

      Set the ratio item attribute.                   


      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetRatio** `(self, width, height)`
      
      
      
      
      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetRatio** `(self, size)`
      
      
      
      
      :param `size`: 
      :type `size`: wx.Size
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetRatio** `(self, ratio)`
      
      
      
      
      :param `ratio`: 
      :type `ratio`: float
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetUserData(self, userData)




      :param `userData`: 
      :type `userData`: PyUserData







   .. method:: Show(self, show)

      Set the show item attribute, which sizers use to determine if the item is to be made part of the layout or not.                  

      If the item is tracking a window then it is shown or hidden as needed.                  


      :param `show`: 
      :type `show`: bool







   .. attribute:: Border

      See :meth:`~wx.SizerItem.GetBorder` and :meth:`~wx.SizerItem.SetBorder`


   .. attribute:: Flag

      See :meth:`~wx.SizerItem.GetFlag` and :meth:`~wx.SizerItem.SetFlag`


   .. attribute:: Id

      See :meth:`~wx.SizerItem.GetId` and :meth:`~wx.SizerItem.SetId`


   .. attribute:: MinSize

      See :meth:`~wx.SizerItem.GetMinSize` and :meth:`~wx.SizerItem.SetMinSize`


   .. attribute:: Position

      See :meth:`~wx.SizerItem.GetPosition`


   .. attribute:: Proportion

      See :meth:`~wx.SizerItem.GetProportion` and :meth:`~wx.SizerItem.SetProportion`


   .. attribute:: Ratio

      See :meth:`~wx.SizerItem.GetRatio` and :meth:`~wx.SizerItem.SetRatio`


   .. attribute:: Rect

      See :meth:`~wx.SizerItem.GetRect`


   .. attribute:: Size

      See :meth:`~wx.SizerItem.GetSize`


   .. attribute:: Sizer

      See :meth:`~wx.SizerItem.GetSizer`


   .. attribute:: Spacer

      See :meth:`~wx.SizerItem.GetSpacer`


   .. attribute:: UserData

      See :meth:`~wx.SizerItem.GetUserData` and :meth:`~wx.SizerItem.SetUserData`


   .. attribute:: Window

      See :meth:`~wx.SizerItem.GetWindow`

