{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import datetime as dt\n", "import panel as pn\n", "\n", "pn.extension()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The ``DatetimeRangeInput`` widget allows selecting a datetime range using two [`DatetimeInput`](./DatetimeInput.ipynb) widgets, which return a tuple range.\n", "\n", "For more information about listening to widget events and laying out widgets refer to the [widgets user guide](../../user_guide/Widgets.ipynb). Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the [param user guide](../../user_guide/Param.ipynb). To express interactivity entirely using Javascript without the need for a Python server take a look at the [links user guide](../../user_guide/Param.ipynb).\n", "\n", "#### Parameters:\n", "\n", "For layout and styling related parameters see the [customization user guide](../../user_guide/Customization.ipynb).\n", "\n", "\n", "##### Core\n", "\n", "* **``format``** (str): Datetime formatting string that determines how the value is formatted and parsed (``default='%Y-%m-%d %H:%M:%S'``)\n", "* **``start``** (datetime): The range's lower bound\n", "* **``end``** (datetime): The range's upper bound\n", "* **``value``** (tuple): Tuple of upper and lower bounds of the selected range expressed as datetime types\n", "\n", "##### Display\n", "\n", "* **``disabled``** (boolean): Whether the widget is editable\n", "* **``name``** (str): The title of the widget\n", "\n", "___\n", "\n", "The 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)`\":" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "datetime_range_input = pn.widgets.DatetimeRangeInput(\n", " name='Datetime Range Input',\n", " start=dt.datetime(2017, 1, 1), end=dt.datetime(2019, 1, 1),\n", " value=(dt.datetime(2017, 1, 1), dt.datetime(2018, 1, 10)),\n", " width=300\n", ")\n", "\n", "datetime_range_input" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "``DatetimeRangeInput.value`` returns a tuple of datetime values that can be read out and set like other widgets:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "datetime_range_input.value" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Controls\n", "\n", "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:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pn.Row(datetime_range_input.controls(jslink=False), datetime_range_input)" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }