Window
Controls the app window.
Limitation:
This control is for Desktop platforms (macOS, Windows, Linux) only.
Inherits: BaseControl
Properties
alignment- Defines the alignment of the app window.always_on_bottom- Whether the app window should always be displayed below other windows.always_on_top- Whether the app window should always be displayed on top of other windows/apps.aspect_ratio- Defines the aspect ratio of the app window.badge_label- Sets a badge label on the app window.bgcolor- Sets background color of an application window.brightness- The brightness of a app window.focused- Whether the app window should be focused.frameless- Whether the app window should be frameless.full_screen- Whether to switch the app's window to fullscreen mode.height- Defines the height of the app window.icon- The icon of the app window.ignore_mouse_events- Whether the app window should ignore mouse events, passing them to the window below it.left- Defines the horizontal position of the app window - a distance in virtual pixels from the left edge of the screen.max_height- Defines the maximum height of the app window.max_width- Defines the maximum width of the app window.maximizable- Whether to hide/disable app window's "Maximize" button.maximized- Whether the app window is maximized.min_height- Defines the minimum height of the app window.min_width- Defines the minimum width of the app window.minimizable- Whether the app window can be minimized through the window's "Minimize" button.minimized- Whether the app window is minimized.movable- Whether the app window can be moved.opacity- Defines the opacity of the app window.prevent_close- Set toTrueto intercept the native close signal.progress_bar- The value from0.0to1.0to display a progress bar on Task Bar or Dock.resizable- Whether the app window can be resized.shadow- Whether to display a shadow around the app window.skip_task_bar- Whether the app window should be hidden from the Task Bar (on Windows) or Dock (on macOS).title_bar_buttons_hidden- Whether to hide the app window's title bar buttons.title_bar_hidden- Whether to hide the app window's title bar.top- Defines the vertical position of a native OS window - a distance in virtual pixels from the top edge of the screen.visible- Whether to make the app window visible.width- Defines the width of the app window.
Events
on_event- Called when app window changes its state.
Methods
center- Centers the app window.close- Requests graceful closing of the app window.destroy- Destroys the app window.start_dragging- Starts dragging the app window.start_resizing- Starts resizing the app window.to_front- Brings the app window to the front.wait_until_ready_to_show- Waits until the app window is ready to show.
Properties
alignmentclass-attributeinstance-attribute
alignment: Alignment | None = NoneDefines the alignment of the app window.
always_on_bottomclass-attributeinstance-attribute
always_on_bottom: bool = FalseWhether the app window should always be displayed below other windows.
Limitation:
Has effect on Linux and Windows only.
always_on_topclass-attributeinstance-attribute
always_on_top: bool = FalseWhether the app window should always be displayed on top of other windows/apps.
aspect_ratioclass-attributeinstance-attribute
aspect_ratio: Number | None = NoneDefines the aspect ratio of the app window.
badge_labelclass-attributeinstance-attribute
badge_label: str | None = NoneSets a badge label on the app window.
Limitation:
Has effect on macOS only.
bgcolorclass-attributeinstance-attribute
bgcolor: ColorValue | None = NoneSets background color of an application window.
Can be used together with Page.bgcolor to make
a window transparent.
Limitation:
On Linux, a compositor must already be running when the app starts. The window's visual is chosen once before the window is created and cannot be swapped afterwards, so an app that starts before its compositor stays opaque until it is restarted.
brightnessclass-attributeinstance-attribute
brightness: Brightness | None = NoneThe brightness of a app window.
focusedclass-attributeinstance-attribute
focused: bool = TrueWhether the app window should be focused.
Set to True to focus programmatically.
framelessclass-attributeinstance-attribute
frameless: bool = FalseWhether the app window should be frameless.
full_screenclass-attributeinstance-attribute
full_screen: bool = FalseWhether to switch the app's window to fullscreen mode.
heightclass-attributeinstance-attribute
height: Number | None = NoneDefines the height of the app window.
iconclass-attributeinstance-attribute
icon: str | None = NoneThe icon of the app window.
The file should have the .ico extension.
Limitation:
Has effect on Windows only.
ignore_mouse_eventsclass-attributeinstance-attribute
ignore_mouse_events: bool = FalseWhether the app window should ignore mouse events, passing them to the window below it. If this window has focus, it will still receive keyboard events.
leftclass-attributeinstance-attribute
left: Number | None = NoneDefines the horizontal position of the app window - a distance in virtual pixels from the left edge of the screen.
max_heightclass-attributeinstance-attribute
max_height: Number | None = NoneDefines the maximum height of the app window.
max_widthclass-attributeinstance-attribute
max_width: Number | None = NoneDefines the maximum width of the app window.
maximizableclass-attributeinstance-attribute
maximizable: bool = TrueWhether to hide/disable app window's "Maximize" button.
maximizedclass-attributeinstance-attribute
maximized: bool = FalseWhether the app window is maximized.
Set to True to maximize programmatically.
min_heightclass-attributeinstance-attribute
min_height: Number | None = NoneDefines the minimum height of the app window.
min_widthclass-attributeinstance-attribute
min_width: Number | None = NoneDefines the minimum width of the app window.
minimizableclass-attributeinstance-attribute
minimizable: bool = TrueWhether the app window can be minimized through the window's "Minimize" button.
minimizedclass-attributeinstance-attribute
minimized: bool = FalseWhether the app window is minimized.
Set to True to minimize programmatically.
movableclass-attributeinstance-attribute
movable: bool = TrueWhether the app window can be moved.
Limitation:
Has effect on macOS only.
opacityclass-attributeinstance-attribute
opacity: Number = 1.0Defines the opacity of the app window.
Raises:
- ValueError - If it is not between
0.0and1.0inclusive.
prevent_closeclass-attributeinstance-attribute
prevent_close: bool = FalseSet to True to intercept the native close signal.
Could be used to implement app exit confirmation logic.
progress_barclass-attributeinstance-attribute
progress_bar: Number | None = NoneThe value from 0.0 to 1.0 to display a progress bar on Task Bar or Dock.
resizableclass-attributeinstance-attribute
resizable: bool = TrueWhether the app window can be resized.
shadowclass-attributeinstance-attribute
shadow: bool = TrueWhether to display a shadow around the app window.
skip_task_barclass-attributeinstance-attribute
skip_task_bar: bool = FalseWhether the app window should be hidden from the Task Bar (on Windows) or Dock (on macOS).
title_bar_buttons_hiddenclass-attributeinstance-attribute
title_bar_buttons_hidden: bool = FalseWhether to hide the app window's title bar buttons.
Limitation:
Has effect on macOS only.
title_bar_hiddenclass-attributeinstance-attribute
title_bar_hidden: bool = FalseWhether to hide the app window's title bar.
topclass-attributeinstance-attribute
top: Number | None = NoneDefines the vertical position of a native OS window - a distance in virtual pixels from the top edge of the screen.
visibleclass-attributeinstance-attribute
visible: bool = TrueWhether to make the app window visible.
Can be of use when the app starts as hidden.
Events
on_eventclass-attributeinstance-attribute
on_event: EventHandler[WindowEvent] | None = NoneCalled when app window changes its state. For example, when the window is maximized or minimized.
Methods
closeasync
close()Requests graceful closing of the app window.
This sends a native close request equivalent to pressing the window
close button. If prevent_close is enabled, the close may be
intercepted and reported via on_event with
WindowEventType.CLOSE.
wait_until_ready_to_showasync
wait_until_ready_to_show()Waits until the app window is ready to show.