Checkbox¶
Use a checkbox to choose between two mutually exclusive options.
Basic¶
Set mode='check'
to show a checkbox.
keep_signed_in = view(
box('Keep me signed in', mode='check'),
)
view(f'Keep me signed in: {keep_signed_in}.')
Set initial value¶
Set value=True
to pre-select the checkbox.
The mode setting mode='check'
is implied, and can be elided.
keep_signed_in = view(box('Keep me signed in', value=True))
view(f'Keep me signed in: {keep_signed_in}.')
Handle changes immediately¶
Add live
to mode
to handle changes immediately.
keep_signed_in = True
while True:
keep_signed_in = view(
box('Remember me', mode='live', value=keep_signed_in),
"Keep me signed in." if keep_signed_in else "Don't keep me signed in.",
)
Disable¶
Set disabled=True
to disable.