Skip to content

WindowEventType

Type of native desktop window event.

Values are reported in WindowEvent.type and delivered by Window.on_event. Event availability depends on the operating system and underlying window manager.

Inherits: Enum

Properties

  • BLUR

    The window lost focus.

  • CLOSE

    The OS requested the window to close.

  • ENTER_FULL_SCREEN

    The window entered full-screen mode.

  • FOCUS

    The window became focused.

  • HIDE

    The window became hidden.

  • LEAVE_FULL_SCREEN

    The window exited full-screen mode.

  • MAXIMIZE

    The window was maximized.

  • MINIMIZE

    The window was minimized.

  • MOVE

    The window position is changing.

  • MOVED

    The window position changed.

  • RESIZE

    The window size is changing.

  • RESIZED

    The window size changed.

  • RESTORE

    The window was restored from a minimized state.

  • SHOW

    The window became visible.

  • UNMAXIMIZE

    The window exited maximized state.

Examples#

Showcase#

import flet as ft


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

    log = ft.Column(
        spacing=4,
        scroll=ft.ScrollMode.AUTO,
        height=220,
    )

    def add_log(message: str):
        log.controls.insert(0, ft.Text(message, size=12))
        if len(log.controls) > 20:
            log.controls.pop()
        log.update()

    def on_window_event(e: ft.WindowEvent):
        add_log(f"Received: {e.type.name}")

    page.window.on_event = on_window_event

    page.appbar = ft.AppBar(title="WindowEventType Showcase")
    page.add(
        ft.SafeArea(
            content=ft.Column(
                controls=[
                    ft.Text(
                        "Interact with the app window and watch incoming event types."
                    ),
                    ft.Text(
                        "Desktop only. Try focus, blur, resize, move, "
                        "minimize, maximize.",
                        size=11,
                    ),
                    ft.Row(
                        wrap=True,
                        spacing=8,
                        controls=[
                            ft.Container(
                                padding=ft.Padding.symmetric(horizontal=8, vertical=4),
                                border=ft.Border.all(1, ft.Colors.OUTLINE),
                                border_radius=12,
                                content=ft.Text(event_type.name, size=11),
                            )
                            for event_type in ft.WindowEventType
                        ],
                    ),
                    ft.Container(
                        width=720,
                        padding=12,
                        border=ft.Border.all(1, ft.Colors.RED),
                        border_radius=10,
                        bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
                        content=log,
                    ),
                ],
            ),
        )
    )


if __name__ == "__main__":
    ft.run(main)

Properties#

BLUR = 'blur' class-attribute instance-attribute #

The window lost focus.

CLOSE = 'close' class-attribute instance-attribute #

The OS requested the window to close.

ENTER_FULL_SCREEN = 'enter-full-screen' class-attribute instance-attribute #

The window entered full-screen mode.

FOCUS = 'focus' class-attribute instance-attribute #

The window became focused.

HIDE = 'hide' class-attribute instance-attribute #

The window became hidden.

LEAVE_FULL_SCREEN = 'leave-full-screen' class-attribute instance-attribute #

The window exited full-screen mode.

MAXIMIZE = 'maximize' class-attribute instance-attribute #

The window was maximized.

MINIMIZE = 'minimize' class-attribute instance-attribute #

The window was minimized.

MOVE = 'move' class-attribute instance-attribute #

The window position is changing.

MOVED = 'moved' class-attribute instance-attribute #

The window position changed.

RESIZE = 'resize' class-attribute instance-attribute #

The window size is changing.

RESIZED = 'resized' class-attribute instance-attribute #

The window size changed.

RESTORE = 'restore' class-attribute instance-attribute #

The window was restored from a minimized state.

SHOW = 'show' class-attribute instance-attribute #

The window became visible.

UNMAXIMIZE = 'unmaximize' class-attribute instance-attribute #

The window exited maximized state.