ComboBox (hwx.gui)#

class ComboBox(values=None, **kwds)#

Bases: Widget

A ComboBox is used for displaying various options. Only one option can be selected.

Attribute Table#

Name

Type

command

property

Method Table#

Name

Description

get (self)

set (self, value)

setValues (self, values, value=None)

Update options user can select.

Example

from hwx import gui

# This method is called when the the combo bbox value is changed.
def onSelected(event):
output.text = event.value

# ComboBox 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
colors = (("red", "Red"), ("green", "Green"), ("blue", "Blue"),)

# Create a ComboBox to select a color and a label to show its value
combobox = gui.ComboBox(colors,
# value  ="green",   #Uncomment this to set the initial value
command=onSelected, )
output = gui.Label(combobox.value)

frame = gui.HFrame(combobox, 10, output)

show(frame)
property command#

The method called when the value changes.

setValues(values, value=None)#

Update options user can select.

Parameters:

values (list[list[value, label]]) – List of (value, label) pairs.