TimeInput¶
A widget to select a clock time.
Usage¶
import toga
current_time = toga.TimeInput()
Notes¶
This widget supports hours, minutes and seconds. Microseconds will always be returned as zero.
On Android, seconds will also be returned as zero.
Properties that return
datetime.time
objects can also accept:datetime.datetime
: The time portion will be extracted.str
: Will be parsed as an ISO8601 format time string (e.g., “06:12”).
Reference¶
- class toga.TimeInput(id=None, style=None, value=None, min=None, max=None, on_change=None, **kwargs)¶
Bases:
Widget
Create a new TimeInput widget.
- Parameters:
id (str | None) – The ID for the widget.
style (StyleT | None) – A style object. If no style is provided, a default style will be applied to the widget.
value (datetime.time | None) – The initial time to display. If not specified, the current time will be used.
min (datetime.time | None) – The earliest time (inclusive) that can be selected.
max (datetime.time | None) – The latest time (inclusive) that can be selected.
on_change (toga.widgets.timeinput.OnChangeHandler | None) – A handler that will be invoked when the value changes.
kwargs – Initial style properties.
- property max: time¶
The maximum allowable time (inclusive). A value of
None
will be converted into 23:59:59.When setting this property, the current
value
andmin
will be clipped against the new maximum value.
- property min: time¶
The minimum allowable time (inclusive). A value of
None
will be converted into 00:00:00.When setting this property, the current
value
andmax
will be clipped against the new minimum value.
- property on_change: OnChangeHandler¶
The handler to invoke when the time value changes.
- protocol toga.widgets.timeinput.OnChangeHandler¶
-
Classes that implement this protocol must have the following methods / attributes: