Phoenix Logo

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.

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.

events Events Emitted by this Class

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

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

class_hierarchy Class Hierarchy

Inheritance diagram for class RadioBox:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

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

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.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.

See also

Create , wx.Validator



__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.

Parameters:
  • parent (wx.Window) – Parent window. Must not be None.
  • id (wx.WindowID) – Window identifier. The value ID_ANY indicates a default value.
  • label (string) – Label for the static box surrounding the radio buttons.
  • pos (wx.Point) – Window position. If wx.DefaultPosition is specified then a default position is chosen.
  • size (wx.Size) – Window size. If wx.DefaultSize is specified then a default size is chosen.
  • choices (list of strings) – An array of choices with which to initialize the radiobox.
  • majorDimension (int) – 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.
  • style (long) – Window style. See wx.RadioBox.
  • validator (wx.Validator) – Window validator.
  • name (string) – Window name.





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 wx.RadioBox for further details.

Parameters:
  • parent (wx.Window) –
  • id (wx.WindowID) –
  • label (string) –
  • pos (wx.Point) –
  • size (wx.Size) –
  • choices (list of strings) –
  • majorDimension (int) –
  • style (long) –
  • validator (wx.Validator) –
  • name (string) –
Return type:

bool



EnableItem(self, n, enable=True)

Enables or disables an individual button in the radiobox.

Parameters:
  • n (int) – The zero-based button to enable or disable.
  • enable (bool) – True to enable, False to disable.
Return type:

bool

See also

wx.Window.Enable



FindString(self, string, bCase=False)

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

Parameters:
  • string (string) – The string to find.
  • bCase (bool) – Should the search be case-sensitive?
Return type:

int



GetColumnCount(self)

Returns the number of columns in the radiobox.

Return type:int


GetCount(self)

Returns the number of items in the control.

Return type:int

See also

IsEmpty



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.

Parameters:pt (wx.Point) – Point in client coordinates.
Return type:int


GetItemHelpText(self, item)

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

Parameters:item (int) – The zero-based item index.
Return type:string

See also

SetItemHelpText



GetItemLabel(self, n)

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



GetItemToolTip(self, item)

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

Parameters:item (int) –
Return type: wx.ToolTip


GetRowCount(self)

Returns the number of rows in the radiobox.

Return type:int


GetSelection(self)

Returns the index of the selected item or NOT_FOUND if no item is selected.

Return type:int
Returns:The position of the current selection.

Note

This method can be used with single selection list boxes only, you should use wx.ListBox.GetSelections for the list boxes with wx.LB_MULTIPLE style.



GetString(self, n)

Returns the label of the item with the given index.

Parameters:n (int) – The zero-based index.
Return type:string
Returns:The label of the item or an empty string if the position was invalid.


IsItemEnabled(self, n)

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

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

Parameters:n (int) – The zero-based button position.
Return type:bool


IsItemShown(self, n)

Returns True if the item is currently shown or False if it was hidden using 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 and wxUniversal and always returns True in the other ports.

Parameters:n (int) – The zero-based button position.
Return type:bool


SetItemHelpText(self, item, helptext)

Sets the helptext for an item.

Empty string erases any existing helptext.

Parameters:
  • item (int) – The zero-based item index.
  • helptext (string) – The help text to set for the item.

See also

GetItemHelpText



SetItemLabel(self, n, text)

SetItemLabel(self, n, text)

Set the text of the n’th item in the radio box.



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.

Parameters:
  • item (int) – Index of the item the tooltip will be shown for.
  • text (string) – Tooltip text for the item, the tooltip is removed if empty.


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.

Parameters:n (int) –


SetString(self, n, string)

Sets the label for the given item.

Parameters:
  • n (int) – The zero-based item index.
  • string (string) – The label to set.


ShowItem(self, item, show=True)

Shows or hides individual buttons.

Parameters:
  • item (int) – The zero-based position of the button to show or hide.
  • show (bool) – True to show, False to hide.
Return type:

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.

See also

wx.Window.Show


Properties



ColumnCount

See GetColumnCount



Count

See GetCount



RowCount

See GetRowCount



Selection

See GetSelection and SetSelection