File size: 1,635 Bytes
2b4d75c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# Form / Checkbox
# Use checkboxes to switch between two mutually exclusive options.
# #form #checkbox
# ---
from h2o_wave import main, app, Q, ui
@app('/demo')
async def serve(q: Q):
if q.args.show_inputs:
q.page['example'].items = [
ui.text(f'checkbox_unchecked={q.args.checkbox_unchecked}'),
ui.text(f'checkbox_checked={q.args.checkbox_checked}'),
ui.text(f'checkbox_indeterminate={q.args.checkbox_indeterminate}'),
ui.text(f'checkbox_unchecked_disabled={q.args.checkbox_unchecked_disabled}'),
ui.text(f'checkbox_checked_disabled={q.args.checkbox_checked_disabled}'),
ui.text(f'checkbox_indeterminate_disabled={q.args.checkbox_indeterminate_disabled}'),
ui.button(name='show_form', label='Back', primary=True),
]
else:
q.page['example'] = ui.form_card(box='1 1 4 7', items=[
ui.checkbox(name='checkbox_unchecked', label='Not checked'),
ui.checkbox(name='checkbox_checked', label='Checked', value=True),
ui.checkbox(name='checkbox_indeterminate', label='Indeterminate', indeterminate=True),
ui.checkbox(name='checkbox_unchecked_disabled', label='Not checked (Disabled)', disabled=True),
ui.checkbox(name='checkbox_checked_disabled', label='Checked (Disabled)', value=True, disabled=True),
ui.checkbox(name='checkbox_indeterminate_disabled', label='Indeterminate (Disabled)', indeterminate=True,
disabled=True),
ui.button(name='show_inputs', label='Submit', primary=True),
])
await q.page.save()
|