WidgetStack (hwx.gui)#

class WidgetStack(widgets=[], **kwds)#

Bases: Widget

A WidgetStack is used to display one widget at a time, generally depending on conditions or actions of other widgets.

Attribute Table#

Name

Type

visibleWidget

property

widgets

property

Method Table#

Name

Description

clear (self)

Removes all the widgets

get (self)

set (self, value)

Example

from hwx import gui

# Create line edits and displays them based on the value of a radio box
def onClick(event):
field = line_edit1 if event.value == "First" else line_edit2
widgetStack.visibleWidget = field

# a radio button acts as the action and determines which LineEdit widget 
# is in the forefront and which goes in the background.
radio_button = gui.HRadioButtons('First Second', command=onClick)

line_edit1 = gui.LineEdit("First")
line_edit2 = gui.LineEdit("Second")

# Create a widgetStack and add the two line_edits as widgets
widgetStack = gui.WidgetStack(widgets=(line_edit1, line_edit2))

frame = gui.VFrame(radio_button, widgetStack)

# Run the demo
show(frame)
property widgets#

The list of stacked widgets.

property visibleWidget#

The visibility of the widget in WidgetStack.

clear()#

Removes all the widgets