TimeInput

A widget to select a clock time.

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, 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)

Bases: Widget

Create a new TimeInput widget.

Parameters:
  • id – The ID for the widget.

  • style – 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 (callable | None) – A handler that will be invoked when the value changes.

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 and min 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 and max will be clipped against the new minimum value.

property on_change: callable

The handler to invoke when the time value changes.

property value: time

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.