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

Checkbox and Group

Checkbox

A single tick box.

with sc.Checkbox('Enable caching', value=True) as box:
    @box.value.on_change
    def _():
        cache_enabled.set(box.value.get())
ArgumentTypeMeaning
labelstr | PropertyLabel
valuebool | PropertyChecked state, default False
label_visibilitystrSee Inputs

Properties: label, value.

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

CheckGroup

A group of tick boxes for choosing several values.

with sc.CheckGroup(
    'Extras',
    options=('Deps', 'Docs', 'Tests'),
    value=('Deps', 'Tests'),
) as group:
    @group.on_change
    def _():
        print(group.value.get())
ArgumentTypeMeaning
labelstr | PropertyLabel
optionssequence, dict, or PropertyChoices
valuesequence | PropertyTicked values
formatcallable or sequenceLabels
horizontalboolLay out in a row
max_heightintCap and scroll the list
enabledbool | PropertyWhether input is accepted
box_disabledcallablePredicate for rows that cannot be ticked
label_visibilitystrSee Inputs

Properties: label, options, value, focused_index.

Signals: on_change (same as value.on_change), options.on_change.

Dictionary form

Passing a dictionary spells each option’s starting state:

sc.CheckGroup('Extras', options={'Deps': True, 'Docs': False})

The keys become options, and value becomes a list of booleans parallel to options, not a subset of them. This is useful when a caller wants to keep the flags in a fixed order.

Focused row

focused_index is the row the client last clicked, or -1. It can drive an action that applies to the highlighted row:

sc.Button(
    'Open',
    enabled=sc.bind(group.focused_index, lambda i: i >= 0),
)