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

==========================================================================================================================================
|phoenix_title|  **wx.RadioBox**
==========================================================================================================================================

A radio box item is used to select one of number of mutually exclusive choices. 
         

It is displayed as a vertical column or horizontal row of labelled buttons. 





.. _RadioBox-styles:

|styles| Window Styles
================================

This class supports the following styles: 

  

- ``wx.RA_SPECIFY_ROWS``: The major dimension parameter refers to the maximum number of rows.  
- ``wx.RA_SPECIFY_COLS``: The major dimension parameter refers to the maximum number of columns.  








.. _RadioBox-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive a :ref:`wx.CommandEvent` parameter.


- EVT_RADIOBOX: Process a  ``wxEVT_RADIOBOX``   event, when a radiobutton is clicked.   









         



.. seealso:: :ref:`Events and Event Handling <events and event handling>`, :ref:`wx.RadioButton`, :ref:`wx.CheckBox`    







|

|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>RadioBox</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.RadioBox_inheritance.svg" alt="Inheritance diagram of RadioBox" 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.RadioBox.html" title="A radio box item is used to select one of number of mutually exclusive choices." alt="" coords="154,313,278,341"/> <area shape="rect" id="node2" href="wx.Control.html" title="This is the base class for a control or 'widget'." alt="" coords="69,236,174,265"/> <area shape="rect" id="node3" href="wx.ItemContainerImmutable.html" title="wx.ItemContainer  defines an interface which is implemented by all controls which have string subitems each of which may be selected." alt="" coords="197,236,424,265"/> <area shape="rect" id="node4" href="wx.Window.html" title="wx.Window  is the base class for all windows and represents any visible object on screen." alt="" coords="66,159,177,188"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="A class that can handle events from the windowing system." alt="" coords="55,82,188,111"/> <area shape="rect" id="node6" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="5,5,104,34"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="Add-on base class for a trackable object." alt="" coords="128,5,251,34"/> </map> 
   </p>
   </div>

|


|appearance| Control Appearance
===============================

|

.. container:: control-appearance-figures

   .. figure:: _static/images/widgets/fullsize/wxmsw/wx.radiobox.png
      :alt: wxMSW
      :figclass: appearance-figure

      **wxMSW**


   .. figure:: _static/images/widgets/fullsize/wxmac/wx.radiobox.png
      :alt: wxMAC
      :figclass: appearance-figure

      **wxMAC**


   .. figure:: _static/images/widgets/fullsize/wxgtk/wx.radiobox.png
      :alt: wxGTK
      :figclass: appearance-figure

      **wxGTK**

|


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

================================================================================ ================================================================================
:meth:`~wx.RadioBox.__init__`                                                    Default constructor.
:meth:`~wx.RadioBox.Create`                                                      Creates the radiobox for two-step construction.
:meth:`~wx.RadioBox.EnableItem`                                                  Enables or disables an individual button in the radiobox.
:meth:`~wx.RadioBox.FindString`                                                  Finds a button matching the given string, returning the position if found, or  ``NOT_FOUND``   if not found.
:meth:`~wx.RadioBox.GetClassDefaultAttributes`                                   
:meth:`~wx.RadioBox.GetColumnCount`                                              Returns the number of columns in the radiobox.
:meth:`~wx.RadioBox.GetCount`                                                    Returns the number of items in the control.
:meth:`~wx.RadioBox.GetItemFromPoint`                                            Returns a radio box item under the point, a zero-based item index, or  ``NOT_FOUND``   if no item is under the point.
:meth:`~wx.RadioBox.GetItemHelpText`                                             Returns the helptext associated with the specified `item`  if any or  ``""`` .
:meth:`~wx.RadioBox.GetItemLabel`                                                GetItemLabel(self, n) . string
:meth:`~wx.RadioBox.GetItemToolTip`                                              Returns the tooltip associated with the specified `item`  if any or ``None``.
:meth:`~wx.RadioBox.GetRowCount`                                                 Returns the number of rows in the radiobox.
:meth:`~wx.RadioBox.GetSelection`                                                Returns the index of the selected item.
:meth:`~wx.RadioBox.GetString`                                                   Returns the label of the item with the given index.
:meth:`~wx.RadioBox.IsItemEnabled`                                               Returns ``True`` if the item is enabled or ``False`` if it was disabled using :meth:`~RadioBox.Enable` .
:meth:`~wx.RadioBox.IsItemShown`                                                 Returns ``True`` if the item is currently shown or ``False`` if it was hidden using :meth:`~RadioBox.Show` .
:meth:`~wx.RadioBox.SetItemHelpText`                                             Sets the helptext for an item.
:meth:`~wx.RadioBox.SetItemLabel`                                                SetItemLabel(self, n, text)
:meth:`~wx.RadioBox.SetItemToolTip`                                              Sets the tooltip text for the specified item in the radio group.
:meth:`~wx.RadioBox.SetSelection`                                                Sets the selection to the given item.
:meth:`~wx.RadioBox.SetString`                                                   Sets the label for the given item.
:meth:`~wx.RadioBox.ShowItem`                                                    Shows or hides individual buttons.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.RadioBox.ColumnCount`                                                 See :meth:`~wx.RadioBox.GetColumnCount`
:attr:`~wx.RadioBox.Count`                                                       See :meth:`~wx.RadioBox.GetCount`
:attr:`~wx.RadioBox.RowCount`                                                    See :meth:`~wx.RadioBox.GetRowCount`
:attr:`~wx.RadioBox.Selection`                                                   See :meth:`~wx.RadioBox.GetSelection` and :meth:`~wx.RadioBox.SetSelection`
================================================================================ ================================================================================


|


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


.. class:: wx.RadioBox(Control, ItemContainerImmutable)

   **Possible constructors**::

       RadioBox() -> None
       
       RadioBox(parent : Window, id: int=ID_ANY, label: str='', pos:
                Point=DefaultPosition, size: Size=DefaultSize, choices: List[str]=[],
                majorDimension: int=0, style: int=RA_SPECIFY_COLS, validator:
                Validator=DefaultValidator, name: str=RadioBoxNameStr) -> None
       
   
   A radio box item is used to select one of number of mutually exclusive
   choices.



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



      |overload| **Overloaded Implementations:**

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

      
      **__init__** `(self)`
      
      Default constructor. 
                       
      
      
                      
      
      :rtype: `None`     
      
      
      
      
      
      
      
      .. seealso:: :meth:`Create` , :ref:`wx.Validator`    
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, parent : Window, id: int=ID_ANY, label: str='', pos: Point=DefaultPosition, size: Size=DefaultSize, choices: List[str]=[], majorDimension: int=0, style: int=RA_SPECIFY_COLS, validator: Validator=DefaultValidator, name: str=RadioBoxNameStr)`
      
      Constructor, creating and showing a radiobox. 
                       
      
      
      
      
      :param `parent`: Parent window. Must not be ``None``.   
      :type `parent`: wx.Window
      :param `id`: Window identifier. The value  ``ID_ANY``   indicates a default value.    
      :type `id`: wx.WindowID
      :param `label`: Label for the static box surrounding the radio buttons.   
      :type `label`: string
      :param `pos`: Window position. If `wx.DefaultPosition`       is specified then a default position is chosen.   
      :type `pos`: wx.Point
      :param `size`: Window size. If `wx.DefaultSize`       is specified then a default size is chosen.   
      :type `size`: wx.Size
      :param `choices`: An array of choices with which to initialize the radiobox.   
      :type `choices`: list of strings
      :param `majorDimension`: Specifies the maximum number of rows (if style contains  ``RA_SPECIFY_ROWS`` ) or columns (if style contains   ``RA_SPECIFY_COLS`` ) for a two-dimensional radiobox. The default value of 0 means to use the number of items, i.e. number of elements in   `choices`.   
      :type `majorDimension`: int
      :param `style`: Window style. See :ref:`wx.RadioBox`.   
      :type `style`: long
      :param `validator`: Window validator.   
      :type `validator`: wx.Validator
      :param `name`: Window name.  
      :type `name`: string
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      :rtype: `None`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Create(self, parent : Window, id: int=ID_ANY, label: str='', pos: Point=DefaultPosition, size: Size=DefaultSize, choices: List[str]=[], majorDimension: int=0, style: int=RA_SPECIFY_COLS, validator: Validator=DefaultValidator, name: str=RadioBoxNameStr)

      Creates the radiobox for two-step construction. 
                 

      See :ref:`wx.RadioBox`  for further details. 
                 


      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `label`: 
      :type `label`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `choices`: 
      :type `choices`: list of strings
      :param `majorDimension`: 
      :type `majorDimension`: int
      :param `style`: 
      :type `style`: long
      :param `validator`: 
      :type `validator`: wx.Validator
      :param `name`: 
      :type `name`: string




      :rtype: `bool`








   .. method:: EnableItem(self, n : int, enable: bool=True)

      Enables or disables an individual button in the radiobox. 
                 




      :param `n`: The zero-based button to enable or disable.  
      :type `n`: int
      :param `enable`: ``True`` to enable, ``False`` to disable.   
      :type `enable`: bool








      :rtype: `bool`




                  



      .. seealso:: :meth:`wx.Window.Enable`     








   .. method:: FindString(self, string : str, bCase: bool=False)

      Finds a button matching the given string, returning the position if found, or  ``NOT_FOUND``   if not found.  
                 




      :param `string`: The string to find.   
      :type `string`: string
      :param `bCase`: Should the search be case-sensitive?   
      :type `bCase`: bool








      :rtype: `int`




                  





   .. staticmethod:: GetClassDefaultAttributes(variant: WindowVariant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: :ref:`wx.VisualAttributes`








   .. method:: GetColumnCount(self)

      Returns the number of columns in the radiobox. 
                 

      :rtype: `int`








   .. method:: GetCount(self)

      Returns the number of items in the control. 
                 


                

      :rtype: `int`







      .. seealso:: :meth:`~wx.ItemContainerImmutable.IsEmpty`     








   .. method:: GetItemFromPoint(self, pt : Point)

      Returns a radio box item under the point, a zero-based item index, or  ``NOT_FOUND``   if no item is under the point.  
                 




      :param `pt`: Point in client coordinates.   
      :type `pt`: wx.Point






      :rtype: `int`




                  





   .. method:: GetItemHelpText(self, item : int)

      Returns the helptext associated with the specified `item`  if any or  ``""`` .  
                 




      :param `item`: The zero-based item index.  
      :type `item`: int






      :rtype: `str`




                  



      .. seealso:: :meth:`SetItemHelpText`     








   .. method:: GetItemLabel(self, n)

      
      Return the text of the n'th item in the radio box.



   .. method:: GetItemToolTip(self, item : int)

      Returns the tooltip associated with the specified `item`  if any or ``None``. 
                 


                


      :param `item`: 
      :type `item`: int




      :rtype: :ref:`wx.ToolTip`







      .. seealso:: :meth:`SetItemToolTip` , :meth:`wx.Window.GetToolTip`     








   .. method:: GetRowCount(self)

      Returns the number of rows in the radiobox. 
                 

      :rtype: `int`








   .. method:: GetSelection(self)

      Returns the index of the selected item. 
                 

      As radio boxes always have a selected item, the return value is never  ``NOT_FOUND``   for this class.  
                 

      :rtype: `int`








   .. method:: GetString(self, n : int)

      Returns the label of the item with the given index. 
                 

      The index must be valid, i.e. less than the value returned by :meth:`GetCount` , otherwise an assert is triggered. Notably, this function can't be called if the control is empty. 




      :param `n`: The zero-based index.  
      :type `n`: int






      :rtype: `str`




                  



      :returns: 

         The label of the item.   








   .. method:: IsItemEnabled(self, n : int)

      Returns ``True`` if the item is enabled or ``False`` if it was disabled using :meth:`Enable` . 
                 

      This function is currently only implemented in wxMSW, wxGTK, ``QT`` and wxUniversal and always returns ``True`` in the other ports. 




      :param `n`: The zero-based button position.   
      :type `n`: int






      :rtype: `bool`




                  





   .. method:: IsItemShown(self, n : int)

      Returns ``True`` if the item is currently shown or ``False`` if it was hidden using :meth:`Show` . 
                 

      Note that this function returns ``True`` for an item which hadn't been hidden even if the entire radiobox is not currently shown. 

      This function is currently only implemented in wxMSW, wxGTK, ``QT`` and wxUniversal and always returns ``True`` in the other ports. 




      :param `n`: The zero-based button position.   
      :type `n`: int






      :rtype: `bool`




                  





   .. method:: SetItemHelpText(self, item : int, helptext : str)

      Sets the helptext for an item. 
                 

      Empty string erases any existing helptext. 




      :param `item`: The zero-based item index.   
      :type `item`: int
      :param `helptext`: The help text to set for the item.  
      :type `helptext`: string








      :rtype: `None`     




                  



      .. seealso:: :meth:`GetItemHelpText`     








   .. method:: SetItemLabel(self, n, text)

      SetItemLabel(self, n, text)
      
      Set the text of the n'th item in the radio box.



   .. method:: SetItemToolTip(self, item : int, text : str)

      Sets the tooltip text for the specified item in the radio group. 
                 

      This function is currently only implemented in wxMSW and wxGTK2 and does nothing in the other ports. 




      :param `item`: Index of the item the tooltip will be shown for.   
      :type `item`: int
      :param `text`: Tooltip text for the item, the tooltip is removed if empty.  
      :type `text`: string








      :rtype: `None`     




                  



      .. seealso:: :meth:`GetItemToolTip` , :meth:`wx.Window.SetToolTip`     








   .. method:: SetSelection(self, n : int)

      Sets the selection to the given item. 
                 

      Notice that a radio box always has selection, so `n`  must be valid here and passing  ``NOT_FOUND``   is not allowed.  
                 


      :param `n`: 
      :type `n`: int




      :rtype: `None`     








   .. method:: SetString(self, n : int, string : str)

      Sets the label for the given item. 
                 




      :param `n`: The zero-based item index.   
      :type `n`: int
      :param `string`: The label to set.   
      :type `string`: string








      :rtype: `None`     




                  





   .. method:: ShowItem(self, item : int, show: bool=True)

      Shows or hides individual buttons. 
                 




      :param `item`: The zero-based position of the button to show or hide.  
      :type `item`: int
      :param `show`: ``True`` to show, ``False`` to hide.   
      :type `show`: bool








      :rtype: `bool`




                  



      :returns: 

         ``True`` if the item has been shown or hidden or ``False`` if nothing was done because it already was in the requested state.  







      .. seealso:: :meth:`wx.Window.Show`     








   .. attribute:: ColumnCount

      See :meth:`~wx.RadioBox.GetColumnCount`


   .. attribute:: Count

      See :meth:`~wx.RadioBox.GetCount`


   .. attribute:: RowCount

      See :meth:`~wx.RadioBox.GetRowCount`


   .. attribute:: Selection

      See :meth:`~wx.RadioBox.GetSelection` and :meth:`~wx.RadioBox.SetSelection`