Skip to content

Time Picker

Use a time picker to pick a time using a 12- or 24-hour clock.

Basic

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

time = view(box('Set alarm for:', mode='time', value='3:04PM'))
view(f'Alarm set for {time}.')

Screenshot

Enable seconds

Include seconds in the value to show a seconds component.

time = view(box('Set alarm for:', mode='time', value='3:04:05PM'))
view(f'Alarm set for {time}.')

Screenshot

Show hours only

Exclude minutes and seconds from the value to show only the hour component.

time = view(box('Set alarm for:', mode='time', value='3PM'))
view(f'Alarm set for {time}.')

Screenshot

Show 24-hour clock

Exclude AM or PM from the value to accept input in military time.

time = view(box('Set alarm for:', mode='time', value='15:04'))
view(f'Alarm set for {time}.')

Screenshot

Show 24-hour clock, with seconds

Include seconds in the value to show a seconds component.

time = view(box('Set alarm for:', mode='time', value='15:04:05'))
view(f'Alarm set for {time}.')

Screenshot

Show 24-hour clock, with hour only

Exclude minutes and seconds from the value to show only the hour component.

time = view(box('Set alarm for:', mode='time', value='15'))
view(f'Alarm set for {time}.')

Screenshot

Handle changes immediately

Add live to mode to handle changes immediately.

time = '3:04PM'
while True:
    time = view(
        box('Set alarm for:', mode='live time', value=time),
        f'Alarm will be set for {time}.',
    )

Screenshot

Disable

Set disabled=True to disable.

view(box('Set alarm for:', mode='time', value='3:04PM', disabled=True))

Screenshot