TimePicker
Time Picker
Introduction
TimePicker is a widget in Supervisely that allows to select time input.
Function signature
TimePicker(
start="09:00",
step="00:15",
end="22:30",
placeholder=None,
size=None,
readonly=False,
disabled=False,
editable=True,
clearable=True,
widget_id=None,
)
Parameters
value
str
TimePicker value
start
str
Start time
step
str
Time step
end
str
End time
placeholder
str
TimePicker placeholder
size
Literal["large", "small", "mini", None]
Size of input
readonly
bool
Whether TimePicker is read only
disabled
bool
Whether TimePicker is disabled
editable
bool
Whether the input is editable
clearable
bool
Whether to show clear button
widget_id
str
ID of the widget
start
Determine TimePicker start time.
type: str
default value: "09:00"
step
Determine TimePicker time step.
type: str
default value: "00:15"
end
Determine TimePicker end time.
type: str
default value: "22:30"
time_picker = TimePicker(start="06:30", step="00:30", end="15:00")
placeholder
Determine TimePicker placeholder.
type: str
default value: None
time_picker = TimePicker(placeholder="Select time")
size
Determine TimePicker size of input.
type: Literal["large", "small", "mini", None]
default value: None
text = Text()
time_picker = TimePicker()
time_picker_mini = TimePicker(size="mini")
time_picker_small = TimePicker(size="small")
time_picker_large = TimePicker(size="large")
readonly
Determine whether TimePicker is read only.
type: bool
default value: False
time_picker = TimePicker(readonly=True)
editable
Determine whether the input is editable.
type: bool
default value: True
clearable
Determine whether to show a clear button.
type: bool
default value: True
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
set_value()
Set TimePicker current value.
get_value()
Return TimePicker current value.
get_picker_options()
Return TimePicker options(start, step, end).
set_start(value: str)
Set TimePicker start time.
set_end(value: str)
Set TimePicker time step.
set_step(value: str)
Set TimePicker end time.
@value_changed
Decorator function to handle TimePicker click.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/input/008_time_picker/src/main.py
Import libraries
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, Text, TimePickerInit API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()Initialize TimePicker and Text widgets
TimePicker and Text widgetstime_picker = TimePicker()
text = Text()Create app layout
Prepare a layout for app using Card widget with the content parameter.
card = Card(
"Time Picker",
content=Container([time_picker, text]),
)
layout = Container(widgets=[card])Create app using layout
Create an app object with layout parameter.
app = sly.Application(layout=card)Add functions to control widgets from python code
@time_picker.value_changed
def show_time(res):
info = f"Selected time: {res}"
text.set(text=info, status="info")
Last updated
Was this helpful?