Month Picker¶
Use a month picker to pick a month in a given range.
Basic¶
Set mode='month'
to show a month picker.
Set initial month¶
Set value=
to pre-select a month.
Dates must be in ISO 8601 format. Date-only strings (e.g. "1970-01-01") are treated as UTC, not local.
Set min date¶
Set min=
to specify a minimum date.
month = view(box('Pick a month', mode='month', value='2021-10-10', min='2019-01-01'))
view(f'You picked {month}.')
Set max date¶
Set max=
to specify a maximum date.
month = view(box('Pick a month', mode='month', value='2021-10-10', max='2022-12-31'))
view(f'You picked {month}.')
Combine min and max dates¶
Set both min=
and max=
to restrict selection between two dates.
month = view(box('Pick a month', mode='month', value='2021-10-10', min='2019-01-01', max='2022-12-31'))
view(f'You picked {month}.')
Set range¶
Set range=
to a (min, max)
tuple to restrict selection between two dates.
This is a shorthand notation for setting min=
and max=
individually.
month = view(box('Pick a month', mode='month', value='2021-10-10', range=('2019-01-01', '2022-12-31')))
view(f'You picked {month}.')
Handle changes immediately¶
Add live
to mode
to handle changes immediately.
month = '2021-10-10'
while True:
month = view(
box('Pick a month', mode='live month', value=month),
f'You picked {month} (UTC).'
)
Disable¶
Set disabled=True
to disable.