.. 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 `, :ref:`wx.RadioButton`, :ref:`wx.CheckBox` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class RadioBox:
| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/wx.radiobox.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/wx.radiobox.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/wx.radiobox.png :alt: wxGTK :figclass: floatcenter **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() RadioBox(parent, id=ID_ANY, label="", pos=DefaultPosition, size=DefaultSize, choices=[], majorDimension=0, style=RA_SPECIFY_COLS, validator=DefaultValidator, name=RadioBoxNameStr) A radio box item is used to select one of number of mutually exclusive choices. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **__init__** `(self)` Default constructor. .. seealso:: :meth:`Create` , :ref:`wx.Validator` :html:`

` **__init__** `(self, parent, id=ID_ANY, label="", pos=DefaultPosition, size=DefaultSize, choices=[], majorDimension=0, style=RA_SPECIFY_COLS, validator=DefaultValidator, name=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 :html:`

` .. method:: Create(self, parent, id=ID_ANY, label="", pos=DefaultPosition, size=DefaultSize, choices=[], majorDimension=0, style=RA_SPECIFY_COLS, validator=DefaultValidator, name=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, enable=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, bCase=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=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) 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) Returns the helptext associated with the specified `item` if any or ``""`` . :param `item`: The zero-based item index. :type `item`: int :rtype: `string` .. seealso:: :meth:`SetItemHelpText` .. method:: GetItemLabel(self, n) Return the text of the n'th item in the radio box. .. method:: GetItemToolTip(self, item) 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) 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: `string` :returns: The label of the item. .. method:: IsItemEnabled(self, n) 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) 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, helptext) 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 .. 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, text) 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 .. seealso:: :meth:`GetItemToolTip` , :meth:`wx.Window.SetToolTip` .. method:: SetSelection(self, n) 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 .. method:: SetString(self, n, string) 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 .. method:: ShowItem(self, item, show=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`