Show only one child at any time. Example:

from flexx import app, event, ui

class Example(ui.Widget):

    def init(self):
        with ui.HBox():
            with ui.VBox():
                self.buta = ui.Button(text='red')
                self.butb = ui.Button(text='green')
                self.butc = ui.Button(text='blue')
                ui.Widget(flex=1)  # space filler
            with ui.StackLayout(flex=1) as self.stack:
                self.buta.w = ui.Widget(style='background:#a00;')
                self.butb.w = ui.Widget(style='background:#0a0;')
                self.butc.w = ui.Widget(style='background:#00a;')

    @event.reaction('buta.pointer_down', 'butb.pointer_down', 'butc.pointer_down')
    def _stacked_current(self, *events):
        button = events[-1].source
open in new tab

class flexx.ui.StackLayout(*init_args, **kwargs)

Inherits from: Layout

A layout widget which shows only one of its children at a time.

The node of this widget is a <div>.

properties: current

actions: set_current


ComponentProp – The currently shown widget (or None).


action – Setter for current widget. Can also set using an integer index.