Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Toggle

A sliding on / off switch.

with sc.Toggle('Auto refresh', value=True) as toggle:
    @toggle.value.on_change
    def _():
        auto_refresh.set(toggle.value.get())
ArgumentTypeMeaning
labelstr | PropertyLabel
valuebool | PropertyOn / off state, default False
label_visibilitystrSee Inputs

Properties: label, value.

Signals: value.on_change (toggle['on_value']).

Toggle is an alias of ToggleBox. Its fields match Checkbox; only the visual differs.

Toggle versus ToggleButton

  • ToggleBox (Toggle) is an input widget: it belongs among other form controls and has a label above it.
  • ToggleButton is a button that stays lit. It belongs in a toolbar, and its type is derived from its state.