{ "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 ``TimePicker`` widget allows entering a time value as text or `datetime.time`. \n", "\n", "Discover more on using widgets to add interactivity to your applications in the [how-to guides on interactivity](../how_to/interactivity/index.md). Alternatively, learn [how to set up callbacks and (JS-)links between parameters](../../how_to/links/index.md) or [how to use them as part of declarative UIs with Param](../../how_to/param/index.html).\n", "\n", "#### Parameters:\n", "\n", "For details on other options for customizing the component see the [layout](../../how_to/layout/index.md) and [styling](../../how_to/styling/index.md) how-to guides.\n", "\n", "##### Core\n", "\n", "* **``value``** (str | datetime.time): The current value\n", "* **``start``** (str | datetime.time): Inclusive lower bound of the allowed time selection\n", "* **``end``** (str | datetime.time): Inclusive upper bound of the allowed time selection\n", "\n", " ```\n", " +---+------------------------------------+------------+\n", " | H | Hours (24 hours) | 00 to 23 |\n", " | h | Hours | 1 to 12 |\n", " | G | Hours, 2 digits with leading zeros | 1 to 12 |\n", " | i | Minutes | 00 to 59 |\n", " | S | Seconds, 2 digits | 00 to 59 |\n", " | s | Seconds | 0, 1 to 59 |\n", " | K | AM/PM | AM or PM |\n", " +---+------------------------------------+------------+\n", " ```\n", " See also https://flatpickr.js.org/formatting/#date-formatting-tokens.\n", "\n", "\n", "\n", "##### Display\n", "\n", "* **``disabled``** (boolean): Whether the widget is editable\n", "* **``name``** (str): The title of the widget\n", "* **``format``** (str): Formatting specification for the display of the picked date.\n", "* **``hour_increment``** (int): Defines the granularity of hour value increments in the UI. Default is 1.\n", "* **``minute_increment``** (int): Defines the granularity of minute value increments in the UI. Default is 1.\n", "* **``second_increment``** (int): Defines the granularity of second value increments in the UI. Default is 1.\n", "* **``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.\n", "* **``clock``** (bool): Whether to use 12 hour or 24 hour clock.\n", "___" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `TimePicker` widget allows selecting a time of day." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "time_picker = pn.widgets.TimePicker(name='Time Picker', value=dt.datetime.now().time(), format='H:i K')\n", "time_picker" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Either `datetime.time` or `str` can be used as input and `TimePicker` can be bounded by a start and end time." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "time_picker = pn.widgets.TimePicker(name='Time Picker', value=\"08:28\", start='00:00', end='12:00')\n", "time_picker" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }