Skip to content
Toga
0.5.3.dev143+gabcc6cdb6

TimeInput

A widget to select a clock time.

/reference/images/timeinput-cocoa.png

Not supported

/reference/images/timeinput-winforms.png

/reference/images/timeinput-android.png

/reference/images/timeinput-iOS.png

/reference/images/timeinput-web.png

Not supported

Usage

import toga

current_time = toga.TimeInput()

Notes

  • This widget supports hours, minutes and seconds. Microseconds will always be returned as zero.
  • On Android and iOS, seconds will also be returned as zero, and any second component of a minimum or maximum value will be ignored.
  • 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

toga.TimeInput

TimeInput(
    id=None,
    style=None,
    value=None,
    min=None,
    max=None,
    on_change=None,
    **kwargs,
)

Bases: Widget

Create a new TimeInput widget.

PARAMETER DESCRIPTION
id

The ID for the widget.

TYPE: str | None DEFAULT: None

style

A style object. If no style is provided, a default style will be applied to the widget.

TYPE: StyleT | None DEFAULT: None

value

The initial time to display. If not specified, the current time will be used.

TYPE: time | None DEFAULT: None

min

The earliest time (inclusive) that can be selected.

TYPE: time | None DEFAULT: None

max

The latest time (inclusive) that can be selected.

TYPE: time | None DEFAULT: None

on_change

A handler that will be invoked when the value changes.

TYPE: OnChangeHandler | None DEFAULT: None

kwargs

Initial style properties.

DEFAULT: {}

max property writable

max

The maximum allowable time (inclusive). A value of None will be converted into 23:59:59.

When setting this property, the current value and min will be clipped against the new maximum value.

min property writable

min

The minimum allowable time (inclusive). A value of None will be converted into 00:00:00.

When setting this property, the current value and max will be clipped against the new minimum value.

on_change property writable

on_change

The handler to invoke when the time value changes.

value property writable

value

The currently selected time. A value of None will be converted into the current time.

If this property is set to a value outside of the min/max range, it will be clipped.

toga.widgets.timeinput.OnChangeHandler

Bases: Protocol

__call__

__call__(widget, **kwargs)

A handler to invoke when the time input is changed.

PARAMETER DESCRIPTION
widget

The TimeInput that was changed.

TYPE: TimeInput

kwargs

Ensures compatibility with arguments added in future versions.

TYPE: Any DEFAULT: {}