Skip to main content

TimePicker

A Fluent time picker: a field showing the hour and minute, which opens scrolling lists to pick each of them.

Example:

fluent.TimePicker(header="Alarm", value=time(7, 30))
TimePicker
TimePicker

Inherits: LayoutControl

Properties

  • autofocus - Whether this picker should be focused on initial display.
  • header - A label shown above the field.
  • minute_increment - The step between the minutes offered: for example, 15 offers 00, 15, 30 and 45.
  • use_24_hour - Whether hours go from 00 to 23, instead of from 1 to 12 with an AM/PM field.
  • value - The selected time.

Events

  • on_change - Called when the user picks a time and confirms it.

Example​

Fluent TimePicker​

Sourceplay_arrowTry Online
from datetime import time

import flet_fluent_ui as fluent

import flet as ft


def main(page: ft.Page):
page.title = "Fluent TimePicker"

def handle_change(e: ft.Event[fluent.TimePicker]):
status.value = f"Meeting at {e.control.value:%H:%M}"

status = ft.Text("Meeting at 14:30")

page.add(
ft.SafeArea(
content=ft.Column(
controls=[
fluent.TimePicker(header="Alarm", value=time(7, 30)),
fluent.TimePicker(
key="meeting",
header="Meeting (every 5 minutes)",
value=time(14, 30),
use_24_hour=True,
minute_increment=5,
on_change=handle_change,
),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
time_picker
Picking an hour

Properties​

autofocusclass-attributeinstance-attribute​

autofocus: bool = False

Whether this picker should be focused on initial display.

headerclass-attributeinstance-attribute​

header: str | None = None

A label shown above the field.

minute_incrementclass-attributeinstance-attribute​

minute_increment: int = 1

The step between the minutes offered: for example, 15 offers 00, 15, 30 and 45.

use_24_hourclass-attributeinstance-attribute​

use_24_hour: bool = False

Whether hours go from 00 to 23, instead of from 1 to 12 with an AM/PM field.

valueclass-attributeinstance-attribute​

value: time | None = None

The selected time.

If None, the field shows placeholders and the lists open at the current time.

Events​

on_changeclass-attributeinstance-attribute​

on_change: ControlEventHandler[TimePicker] | None = None

Called when the user picks a time and confirms it.

value holds the new time.