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.
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.
For details on other options for customizing the component see the layout and styling how-to guides.
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)