HRadioButtons (hwx.gui)#

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

Bases: RadioButtons

Group of mutually exclusive RadioButtons layed out horizontally.


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 Horizontal layout of RadioButtons and a label to show its value
# Try replacing HRadioButtons with VRadioButtons or ComboBox
buttons = gui.HRadioButtons(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)