Legend (hwx.gui)#
- class Legend(parent=None, values=[], **kwds)#
Bases:
Widget
A color coded legend.
A Legend widget contains color and labels. The items in the legend can be selected and an action performed. Legends are used to easily change between discrete values with associated colors.
For example, when defining the type of joint among three options (Active, Locked, Free).
# Name
Type
property
property
# Name
Description
clear
(self)Clears all the legends.
get
(self)Returns the legend value.
setValues
(self, values)List of legend properties to be set.
Example
from hwx import gui # A series of colors, values and labels displayed in the legend State = (("red", "value1", "Red"), ("green", "value2", "Green"), ("blue", "value3", "Blue"),) # This method is called when the a new item from the legend is selected. def onSelected(event): output.text = legend.value legend = gui.Legend(values=State, command=onSelected, # enabled = False, # Uncomment this disable the legend ) output = gui.Label() frame = gui.VFrame(output, legend, ) show(frame)
- property values#
List of (color, value, label) tuples populating the legend.
- setValues(values)#
List of legend properties to be set.
- Parameters:
values (list) – A list of properties.
- property activeValues#
List of values which are not deactivated (shown as transparent).
Pass True to activate or False to deactivate all.
- clear()#
Clears all the legends.
- get()#
Returns the legend value.