WindowEventType
Type of native desktop window event.
Values are reported in flet.WindowEvent.type and delivered by flet.Window.on_event. Event availability depends on the operating system and underlying window manager.
Inherits: enum.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
BLURclass-attributeinstance-attribute
The window lost focus.
CLOSEclass-attributeinstance-attribute
The OS requested the window to close.
ENTER_FULL_SCREENclass-attributeinstance-attribute
The window entered full-screen mode.
FOCUSclass-attributeinstance-attribute
The window became focused.
HIDEclass-attributeinstance-attribute
The window became hidden.
LEAVE_FULL_SCREENclass-attributeinstance-attribute
The window exited full-screen mode.
MAXIMIZEclass-attributeinstance-attribute
The window was maximized.
MINIMIZEclass-attributeinstance-attribute
The window was minimized.
MOVEclass-attributeinstance-attribute
The window position is changing.
MOVEDclass-attributeinstance-attribute
The window position changed.
RESIZEclass-attributeinstance-attribute
The window size is changing.
RESIZEDclass-attributeinstance-attribute
The window size changed.
RESTOREclass-attributeinstance-attribute
The window was restored from a minimized state.
SHOWclass-attributeinstance-attribute
The window became visible.
UNMAXIMIZEclass-attributeinstance-attribute
The window exited maximized state.