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

==========================================================================================================================================
|phoenix_title|  **wx.GridSizer**
==========================================================================================================================================

A grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields having the same size, i.e.          

the width of each field is the width of the widest child, the height of each field is the height of the tallest child. 







         



.. seealso:: :ref:`wx.Sizer`, :ref:`Sizers Overview <sizers overview>`    







|

|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>GridSizer</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.GridSizer_inheritance.png" alt="Inheritance diagram of GridSizer" 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.Sizer.html" title="wx.Sizer" alt="" coords="17,83,91,112"/> <area shape="rect" id="node3" href="wx.GridSizer.html" title="wx.GridSizer" alt="" coords="5,160,104,189"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="13,5,95,35"/> </map> 
   </p>

|


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

:ref:`wx.FlexGridSizer`

|


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

================================================================================ ================================================================================
:meth:`~wx.GridSizer.__init__`                                                   :ref:`wx.GridSizer`  constructors.
:meth:`~wx.GridSizer.CalcMin`                                                    This method is abstract and has to be overwritten by any derived class.
:meth:`~wx.GridSizer.CalcRowsCols`                                               CalcRowsCols() . (rows, cols)
:meth:`~wx.GridSizer.GetCols`                                                    Returns the number of columns that has been specified for the sizer.
:meth:`~wx.GridSizer.GetEffectiveColsCount`                                      Returns the number of columns currently used by the sizer.
:meth:`~wx.GridSizer.GetEffectiveRowsCount`                                      Returns the number of rows currently used by the sizer.
:meth:`~wx.GridSizer.GetHGap`                                                    Returns the horizontal gap (in pixels) between cells in the sizer.
:meth:`~wx.GridSizer.GetRows`                                                    Returns the number of rows that has been specified for the sizer.
:meth:`~wx.GridSizer.GetVGap`                                                    Returns the vertical gap (in pixels) between the cells in the sizer.
:meth:`~wx.GridSizer.RecalcSizes`                                                This method is abstract and has to be overwritten by any derived class.
:meth:`~wx.GridSizer.SetCols`                                                    Sets the number of columns in the sizer.
:meth:`~wx.GridSizer.SetHGap`                                                    Sets the horizontal gap (in pixels) between cells in the sizer.
:meth:`~wx.GridSizer.SetRows`                                                    Sets the number of rows in the sizer.
:meth:`~wx.GridSizer.SetVGap`                                                    Sets the vertical gap (in pixels) between the cells in the sizer.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.GridSizer.Cols`                                                       See :meth:`~wx.GridSizer.GetCols` and :meth:`~wx.GridSizer.SetCols`
:attr:`~wx.GridSizer.EffectiveColsCount`                                         See :meth:`~wx.GridSizer.GetEffectiveColsCount`
:attr:`~wx.GridSizer.EffectiveRowsCount`                                         See :meth:`~wx.GridSizer.GetEffectiveRowsCount`
:attr:`~wx.GridSizer.HGap`                                                       See :meth:`~wx.GridSizer.GetHGap` and :meth:`~wx.GridSizer.SetHGap`
:attr:`~wx.GridSizer.Rows`                                                       See :meth:`~wx.GridSizer.GetRows` and :meth:`~wx.GridSizer.SetRows`
:attr:`~wx.GridSizer.VGap`                                                       See :meth:`~wx.GridSizer.GetVGap` and :meth:`~wx.GridSizer.SetVGap`
================================================================================ ================================================================================


|


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


.. class:: wx.GridSizer(Sizer)

   **Possible constructors**::

       GridSizer(cols, vgap, hgap)
       
       GridSizer(cols, gap=Size(0,0))
       
       GridSizer(rows, cols, vgap, hgap)
       
       GridSizer(rows, cols, gap)
       
   
   A grid sizer is a sizer which lays out its children in a two-
   dimensional table with all table fields having the same size, i.e.



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

      :ref:`wx.GridSizer`  constructors.                  

      Usually only the number of columns in the flex grid sizer needs to be specified using `cols`  argument. The number of rows will be deduced automatically depending on the number of the elements added to the sizer. 

      If a constructor form with `rows`  parameter is used (and the value of `rows`  argument is not zero, meaning "unspecified") the sizer will check that no more than  ``cols*rows``   elements are added to it, i.e. that no more than the given number of  `rows`  is used. Adding less than maximally allowed number of items is not an error however. 

      Finally, it is also possible to specify the number of rows and use 0 for `cols`. In this case, the sizer will use the given fixed number of rows and as many columns as necessary. 

      The `gap`  (or `vgap`  and `hgap`, which correspond to the height and width of the :ref:`wx.Size`  object) argument defines the size of the padding between the rows (its vertical component, or `vgap`) and columns (its horizontal component, or `hgap`), in pixels. 

                 



      .. versionadded:: 2.9.1 
         (except for the four argument overload)   





      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self, cols, vgap, hgap)`
      
      
      
      
      :param `cols`: 
      :type `cols`: int
      :param `vgap`: 
      :type `vgap`: int
      :param `hgap`: 
      :type `hgap`: int
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, cols, gap=Size(0,0))`
      
      
      
      
      :param `cols`: 
      :type `cols`: int
      :param `gap`: 
      :type `gap`: wx.Size
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, rows, cols, vgap, hgap)`
      
      
      
      
      :param `rows`: 
      :type `rows`: int
      :param `cols`: 
      :type `cols`: int
      :param `vgap`: 
      :type `vgap`: int
      :param `hgap`: 
      :type `hgap`: int
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, rows, cols, gap)`
      
      
      
      
      :param `rows`: 
      :type `rows`: int
      :param `cols`: 
      :type `cols`: int
      :param `gap`: 
      :type `gap`: wx.Size
      
      
      
      
      
      
      **~~~**






   .. method:: CalcMin(self)

      This method is abstract and has to be overwritten by any derived class.                  

      Here, the sizer will do the actual calculation of its children's minimal sizes.                  

      :rtype: :ref:`wx.Size`








   .. method:: CalcRowsCols(self)

      
      Calculates how many rows and columns will be in the sizer based
      on the current number of items and also the rows, cols specified
      in the constructor.



   .. method:: GetCols(self)

      Returns the number of columns that has been specified for the sizer.                  

      Returns zero if the sizer is automatically adjusting the number of columns depending on number of its children. To get the effective number of columns or rows being currently used, see :meth:`GetEffectiveColsCount`                    

      :rtype: `int`








   .. method:: GetEffectiveColsCount(self)

      Returns the number of columns currently used by the sizer.                  

      This will depend on the number of children the sizer has if the sizer is automatically adjusting the number of columns/rows. 

                

      :rtype: `int`







      .. versionadded:: 2.9.1 
     








   .. method:: GetEffectiveRowsCount(self)

      Returns the number of rows currently used by the sizer.                  

      This will depend on the number of children the sizer has if the sizer is automatically adjusting the number of columns/rows. 

                

      :rtype: `int`







      .. versionadded:: 2.9.1 
     








   .. method:: GetHGap(self)

      Returns the horizontal gap (in pixels) between cells in the sizer.                  

      :rtype: `int`








   .. method:: GetRows(self)

      Returns the number of rows that has been specified for the sizer.                  

      Returns zero if the sizer is automatically adjusting the number of rows depending on number of its children. To get the effective number of columns or rows being currently used, see :meth:`GetEffectiveRowsCount` .                  

      :rtype: `int`








   .. method:: GetVGap(self)

      Returns the vertical gap (in pixels) between the cells in the sizer.                  

      :rtype: `int`








   .. method:: RecalcSizes(self)

      This method is abstract and has to be overwritten by any derived class.                  

      Here, the sizer will do the actual calculation of its children's positions and sizes.                   





   .. method:: SetCols(self, cols)

      Sets the number of columns in the sizer.                  


      :param `cols`: 
      :type `cols`: int







   .. method:: SetHGap(self, gap)

      Sets the horizontal gap (in pixels) between cells in the sizer.                  


      :param `gap`: 
      :type `gap`: int







   .. method:: SetRows(self, rows)

      Sets the number of rows in the sizer.                  


      :param `rows`: 
      :type `rows`: int







   .. method:: SetVGap(self, gap)

      Sets the vertical gap (in pixels) between the cells in the sizer.                  


      :param `gap`: 
      :type `gap`: int







   .. attribute:: Cols

      See :meth:`~wx.GridSizer.GetCols` and :meth:`~wx.GridSizer.SetCols`


   .. attribute:: EffectiveColsCount

      See :meth:`~wx.GridSizer.GetEffectiveColsCount`


   .. attribute:: EffectiveRowsCount

      See :meth:`~wx.GridSizer.GetEffectiveRowsCount`


   .. attribute:: HGap

      See :meth:`~wx.GridSizer.GetHGap` and :meth:`~wx.GridSizer.SetHGap`


   .. attribute:: Rows

      See :meth:`~wx.GridSizer.GetRows` and :meth:`~wx.GridSizer.SetRows`


   .. attribute:: VGap

      See :meth:`~wx.GridSizer.GetVGap` and :meth:`~wx.GridSizer.SetVGap`

