TimePicker#

Download this notebook from GitHub (right-click to download).


import datetime as dt

import panel as pn
import panel_material_ui as pmui

pn.extension()

The TimePicker widget allows entering a time value as text or datetime.time.

Discover more on using widgets to add interactivity to your applications in the how-to guides on interactivity. Alternatively, learn how to set up callbacks and (JS-)links between parameters or how to use them as part of declarative UIs with Param.

Parameters:#

For details on other options for customizing the component see the customization guides.

Core#

  • disabled (boolean): Whether the widget is editable

  • end (str | datetime.time): Inclusive upper bound of the allowed time selection

  • start (str | datetime.time): Inclusive lower bound of the allowed time selection

  • value (str | datetime.time): The current value

Display#

  • clock (str): Whether to use 12 hour or 24 hour clock. Default is '12h'.

  • format (str): Formatting specification for the display of the picked date.

    +----+------------------------------------+------------+
    | H  | Hours                              | 0 to 23    |
    | HH | Hours, 2-digits                    | 00 to 23   |
    | h  | Hours, 12-hour clock               | 1 to 12    |
    | hh | Hours, 12-hour clock, 2-digits     | 1 to 12    |
    | m  | Minutes                            | 0 to 59    |
    | mm | Minutes                            | 00 to 59   |
    | s  | Seconds                            | 0, 1 to 59 |
    | ss | Seconds                            | 00 to 59   |
    | a	 | am/pm, lower-case                  | am or pm   |
    | A  | AM/PM, upper-cas                   | AM or PM   |
    +----+------------------------------------+------------+
    

    See also https://day.js.org/docs/en/parse/string-format.

  • hour_increment (int): Defines the granularity of hour value increments in the UI. Default is 1.

  • minute_increment (int): Defines the granularity of minute value increments in the UI. Default is 1.

  • label (str): The title of the widget

  • second_increment (int): Defines the granularity of second value increments in the UI. Default is 1.

  • seconds (bool): Allows to select seconds. By default, only hours and minutes are selectable, and AM/PM depending on the clock option. Default is False.

Styling#

  • sx (dict): Component level styling API.

  • theme_config (dict): Theming API.

Aliases#

For compatibility with Panel certain parameters are allowed as aliases:

  • name: Alias for label


The TimePicker widget allows selecting a time of day.

time_picker = pmui.TimePicker(name='Time Picker', value=dt.datetime.now().time(), format='H:i K')
time_picker

Either datetime.time or str can be used as input and TimePicker can be bounded by a start and end time.

time_picker = pmui.TimePicker(name='Time Picker', value="08:28", start='00:00', end='12:00')

pn.Column(time_picker, height=400)

Download this notebook from GitHub (right-click to download).