Skip to content

DatePickerEntryMode

Mode of date entry method for the date picker dialog.

Inherits: Enum

Properties

  • CALENDAR

    User picks a date from calendar grid.

  • CALENDAR_ONLY

    User can only pick a date from calendar grid.

  • INPUT

    User can input the date by typing it into a text field.

  • INPUT_ONLY

    User can only input the date by typing it into a text field.

Examples#

Showcase#

import datetime

import flet as ft


def main(page: ft.Page):
    page.theme_mode = ft.ThemeMode.DARK
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    today = datetime.datetime.now()
    picker = ft.DatePicker(
        first_date=datetime.datetime(year=today.year - 1, month=1, day=1),
        last_date=datetime.datetime(year=today.year + 1, month=12, day=31),
    )

    def open_picker(entry_mode: ft.DatePickerEntryMode):
        picker.entry_mode = entry_mode
        picker.date_picker_mode = ft.DatePickerMode.DAY
        page.show_dialog(picker)

    def showcase_card(entry_mode: ft.DatePickerEntryMode) -> ft.Container:
        return ft.Container(
            width=320,
            padding=12,
            border=ft.Border.all(1, ft.Colors.RED),
            border_radius=10,
            bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
            content=ft.Column(
                spacing=8,
                controls=[
                    ft.Text(entry_mode.name, weight=ft.FontWeight.BOLD),
                    ft.Button(
                        "Open DatePicker",
                        icon=ft.Icons.CALENDAR_MONTH,
                        on_click=lambda _, m=entry_mode: open_picker(m),
                    ),
                ],
            ),
        )

    page.appbar = ft.AppBar(title="DatePickerEntryMode Showcase")
    page.add(
        ft.Text("Open the picker to compare calendar and input entry modes."),
        ft.Row(
            wrap=True,
            spacing=12,
            expand=True,
            scroll=ft.ScrollMode.AUTO,
            alignment=ft.MainAxisAlignment.CENTER,
            controls=[showcase_card(m) for m in ft.DatePickerEntryMode],
        ),
    )


ft.run(main)

Properties#

CALENDAR = 'calendar' class-attribute instance-attribute #

User picks a date from calendar grid.

Can switch to INPUT by activating a mode button in the dialog.

CALENDAR_ONLY = 'calendarOnly' class-attribute instance-attribute #

User can only pick a date from calendar grid.

There is no user interface to switch to another mode.

INPUT = 'input' class-attribute instance-attribute #

User can input the date by typing it into a text field.

Can switch to CALENDAR by activating a mode button in the dialog.

INPUT_ONLY = 'inputOnly' class-attribute instance-attribute #

User can only input the date by typing it into a text field.

There is no user interface to switch to another mode.