.. include:: headings.inc .. _RadioButton: ========================================================================================================================================== |phoenix_title| **RadioButton** ========================================================================================================================================== A radio button item is a button which usually denotes one of several mutually exclusive options. It has a text label next to a (usually) round button. You can create a group of mutually-exclusive radio buttons by specifying ``RB_GROUP`` for the first in the group. The group ends when another radio button group is created, or there are no more radio buttons. .. _RadioButton-styles: |styles| Window Styles ================================ This class supports the following styles: - ``RB_GROUP``: Marks the beginning of a new group of radio buttons. - ``RB_SINGLE``: In some circumstances, radio buttons that are not consecutive siblings trigger a hang bug in Windows (only). If this happens, add this style to mark the button as not belonging to a group, and implement the mutually-exclusive group behaviour yourself. .. _RadioButton-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`CommandEvent` parameter. - EVT_RADIOBUTTON: Process a ``wxEVT_COMMAND_RADIOBUTTON_SELECTED`` event, when the radiobutton is clicked. .. seealso:: :ref:`Events and Event Handling `, :ref:`RadioBox`, :ref:`CheckBox` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **RadioButton** .. raw:: html

Inheritance diagram of RadioButton

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/radiobutton.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/radiobutton.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/radiobutton.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~RadioButton.__init__` Default constructor. :meth:`~RadioButton.Create` Creates the choice for two-step construction. :meth:`~RadioButton.GetValue` Returns ``True`` if the radio button is checked, ``False`` otherwise. :meth:`~RadioButton.SetValue` Sets the radio button to checked or unchecked status. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~RadioButton.Value` See :meth:`~RadioButton.GetValue` and :meth:`~RadioButton.SetValue` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: RadioButton(Control) A radio button item is a button which usually denotes one of several mutually exclusive options. **Possible constructors**:: RadioButton() RadioButton(parent, id=ID_ANY, label='', pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=RadioButtonNameStr) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` Default constructor. .. seealso:: :meth:`Create` , :ref:`Validator` **~~~** **__init__** `(self, parent, id=ID_ANY, label='', pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=RadioButtonNameStr)` Constructor, creating and showing a radio button. :param `parent`: Parent window. Must not be ``None``. :type `parent`: Window :param `id`: Window identifier. The value ``ID_ANY`` indicates a default value. :type `id`: int :param `label`: Label for the radio button. :type `label`: string :param `pos`: Window position. If ``DefaultPosition`` is specified then a default position is chosen. :type `pos`: Point :param `size`: Window size. If ``DefaultSize`` is specified then a default size is chosen. :type `size`: Size :param `style`: Window style. See :ref:`RadioButton`. :type `style`: long :param `validator`: Window validator. :type `validator`: Validator :param `name`: Window name. :type `name`: string .. seealso:: :meth:`Create` , :ref:`Validator` **~~~** .. method:: Create(self, parent, id=ID_ANY, label='', pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=RadioButtonNameStr) Creates the choice for two-step construction. See :ref:`RadioButton` for further details. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `label`: :type `label`: string :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `validator`: :type `validator`: Validator :param `name`: :type `name`: string :rtype: `bool` .. method:: GetValue(self) Returns ``True`` if the radio button is checked, ``False`` otherwise. :rtype: `bool` .. method:: SetValue(self, value) Sets the radio button to checked or unchecked status. This does not cause a ``wxEVT_COMMAND_RADIOBUTTON_SELECTED`` event to get emitted. If the radio button belongs to a radio group exactly one button in the group may be checked and so this method can be only called with `value` set to ``True``. To uncheck a radio button in a group you must check another button in the same group. :param `value`: ``True`` to check, ``False`` to uncheck. :type `value`: bool .. attribute:: Value See :meth:`~RadioButton.GetValue` and :meth:`~RadioButton.SetValue`