import datetime as dt
import panel as pn
pn.extension()
The DatetimeRangeInput
widget allows selecting a datetime range using two DatetimeInput
widgets, which return a tuple range.
For more information about listening to widget events and laying out widgets refer to the widgets user guide. Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the param user guide. To express interactivity entirely using Javascript without the need for a Python server take a look at the links user guide.
For layout and styling related parameters see the customization user guide.
format
(str): Datetime formatting string that determines how the value is formatted and parsed (default='%Y-%m-%d %H:%M:%S'
)start
(datetime): The range's lower boundend
(datetime): The range's upper boundvalue
(tuple): Tuple of upper and lower bounds of the selected range expressed as datetime typesdisabled
(boolean): Whether the widget is editablename
(str): The title of the widgetThe datetime parser uses the defined format
to validate the input value, if the entered text is not a valid datetime a warning will be shown in the title as "(invalid)
":
datetime_range_input = pn.widgets.DatetimeRangeInput(
name='Datetime Range Input',
start=dt.datetime(2017, 1, 1), end=dt.datetime(2019, 1, 1),
value=(dt.datetime(2017, 1, 1), dt.datetime(2018, 1, 10)),
width=300
)
datetime_range_input
DatetimeRangeInput.value
returns a tuple of datetime values that can be read out and set like other widgets:
datetime_range_input.value
The DatetimeRangeInput
widget is a composite widget, which requires Python for communication. Therefore the controls only work when connected in a live Python server/kernel:
pn.Row(datetime_range_input.controls(jslink=False), datetime_range_input)