RadioButtons (hwx.gui)#

class RadioButtons(values, value=0, **kwds)#

Bases: Widget

Group of mutually exclusive RadioButtons.

RadioButtons are mutually exclusive with other RadioButtons in the same container.

Only one radio botton can be switched on within the same container.

RadioButtons are usually used to create composite controls like VRadioButtons or HRadioButtons.

Method Table#



clear (self)

Destroys the button.

setValues (self, values, value=None)

Specify the options. A button is created for each option.


from hwx import gui

# This method is called when the any radio button is pushed.
def onSelected(event):
  output.text = event.value

# These values are a list of tuples. Each entry is a (value, text)
# The value is what is used by the value property.
# The text is what is displayed to the user.
colors = (("red", "Red"), ("green", "Green"), ("blue", "Blue"),)

# Create a Vertical layout of RadioButtons and a label to show its value
# Try replacing VRadioButtons with HRadioButtons or ComboBox
buttons = gui.VRadioButtons(colors,
  # value  ="green",   #Uncomment this to set the initial value
  command=onSelected, )
output = gui.Label(buttons.value)

frame = gui.HFrame(buttons, 10, (output, "<->"), spacing=5)


Set the item checked.


v (int) – Index of the item to checked.


Returns the checked item.

setValues(values, value=None)#

Specify the options. A button is created for each option.

  • values (list[str, str]) – list of (value, displayName) tuples.

  • value (list[str] | list[int]) – Set new values.


Destroys the button.