Skip to content

Week Picker

Use a week picker to pick a week in a given range.

Basic

Set mode='week' to show a week picker.

week = view(box('Pick a week', mode='week'))
view(f'You picked {week}.')

Screenshot

Set initial week

Set value= to pre-select a week.

Dates must be in ISO 8601 format. Date-only strings (e.g. "1970-01-01") are treated as UTC, not local.

week = view(box('Pick a week', mode='week', value='2021-10-10'))
view(f'You picked {week}.')

Screenshot

Set min date

Set min= to specify a minimum date.

week = view(box('Pick a week', mode='week', value='2021-10-10', min='2019-01-01'))
view(f'You picked {week}.')

Screenshot

Set max date

Set max= to specify a maximum date.

week = view(box('Pick a week', mode='week', value='2021-10-10', max='2022-12-31'))
view(f'You picked {week}.')

Screenshot

Combine min and max dates

Set both min= and max= to restrict selection between two dates.

week = view(box('Pick a week', mode='week', value='2021-10-10', min='2019-01-01', max='2022-12-31'))
view(f'You picked {week}.')

Screenshot

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.

week = view(box('Pick a week', mode='week', value='2021-10-10', range=('2019-01-01', '2022-12-31')))
view(f'You picked {week}.')

Screenshot

Handle changes immediately

Add live to mode to handle changes immediately.

week = '2021-10-10'
while True:
    week = view(
        box('Pick a week', mode='live week', value=week),
        f'You picked {week} (UTC).'
    )

Screenshot

Disable

Set disabled=True to disable.

view(box('Pick a week', mode='week', disabled=True))

Screenshot