Skip to content

Window

Window #

Bases: BaseControl

Controls the app window.

Note

This control is for Desktop platforms (macOS, Windows, Linux) only.

alignment #

alignment: Alignment | None = None

Defines the alignment of the app window.

always_on_bottom #

always_on_bottom: bool = False

Whether the app window should always be displayed below other windows.

Note

Has effect on Linux and Windows only.

always_on_top #

always_on_top: bool = False

Whether the app window should always be displayed on top of other windows/apps.

aspect_ratio #

aspect_ratio: Number | None = None

Defines the aspect ratio of the app window.

badge_label #

badge_label: str | None = None

Sets a badge label on the app window.

Note

Has effect on macOS only.

bgcolor #

bgcolor: ColorValue | None = None

Sets background color of an application window.

Tip

Can be used together with Page.bgcolor to make a window transparent.

brightness #

brightness: Brightness | None = None

The brightness of a app window.

data #

data: Any = skip_field()

Arbitrary data of any type.

focused #

focused: bool = True

Whether the app window should be focused.

Set to True to focus programmatically.

frameless #

frameless: bool = False

Whether the app window should be frameless.

full_screen #

full_screen: bool = False

Whether to switch the app's window to fullscreen mode.

height #

height: Number | None = None

Defines the height of the app window.

icon #

icon: str | None = None

The icon of the app window.

The file should have the .ico extension.

Note

Has effect on Windows only.

ignore_mouse_events #

ignore_mouse_events: bool = False

Whether 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.

key #

key: (
    str | int | float | bool | ValueKey | ScrollKey | None
) = None

left #

left: Number | None = None

Defines the horizontal position of the app window - a distance in virtual pixels from the left edge of the screen.

max_height #

max_height: Number | None = None

Defines the maximum height of the app window.

max_width #

max_width: Number | None = None

Defines the maximum width of the app window.

maximizable #

maximizable: bool = True

Whether to hide/disable app window's "Maximize" button.

maximized #

maximized: bool = False

Whether the app window is maximized.

Set to True to maximize programmatically.

min_height #

min_height: Number | None = None

Defines the minimum height of the app window.

min_width #

min_width: Number | None = None

Defines the minimum width of the app window.

minimizable #

minimizable: bool = True

Whether the app window can be minimized through the window's "Minimize" button.

minimized #

minimized: bool = False

Whether the app window is minimized.

Set to True to minimize programmatically.

movable #

movable: bool = True

Whether the app window can be moved.

Note

Has effect on macOS only.

on_event #

on_event: EventHandler[WindowEvent] | None = None

Called when app window changes its state. For example, when the window is maximized or minimized.

opacity #

opacity: Number = 1.0

Defines the opacity of the app window.

Note

Must be between 0.0 and 1.0.

page #

page: Page | PageView | None

The page (of type Page or PageView) to which this control belongs to.

parent #

parent: BaseControl | None

The direct ancestor(parent) of this control.

It defaults to None and will only have a value when this control is mounted (added to the page tree).

The Page control (which is the root of the tree) is an exception - it always has parent=None.

prevent_close #

prevent_close: bool = False

Set to True to intercept the native close signal.

Could be used to implement app exit confirmation logic.

progress_bar #

progress_bar: Number | None = None

The value from 0.0 to 1.0 to display a progress bar on Task Bar or Dock.

resizable #

resizable: bool = True

Whether the app window can be resized.

shadow #

shadow: bool = True

Whether to display a shadow around the app window.

skip_task_bar #

skip_task_bar: bool = False

Whether the app window should be hidden from the Task Bar (on Windows) or Dock (on macOS).

title_bar_buttons_hidden #

title_bar_buttons_hidden: bool = False

Whether to hide the app window's title bar buttons.

Note

Has effect on macOS only.

title_bar_hidden #

title_bar_hidden: bool = False

Whether to hide the app window's title bar.

top #

top: Number | None = None

Defines the vertical position of a native OS window - a distance in virtual pixels from the top edge of the screen.

visible #

visible: bool = True

Whether to make the app window visible.

Can be of use when the app starts as hidden.

width #

width: Number | None = None

Defines the width of the app window.

before_event #

before_event(e: ControlEvent)

before_update #

before_update()

This method is called every time when this control is being updated.

Note

Make sure not to call/request an update() here.

center #

center()

Centers the app window.

center_async #

center_async()

Centers the app window.

close #

close()

close_async #

close_async()

destroy #

destroy()

Destroys the app window.

destroy_async #

destroy_async()

Destroys the app window.

did_mount #

did_mount()

init #

init()

is_isolated #

is_isolated()

start_dragging #

start_dragging()

Starts dragging the app window.

start_dragging_async #

start_dragging_async()

Starts dragging the app window.

start_resizing #

start_resizing(edge: WindowResizeEdge)

Starts resizing the app window.

start_resizing_async #

start_resizing_async(edge: WindowResizeEdge)

Starts resizing the app window.

to_front #

to_front()

Brings the app window to the front.

to_front_async #

to_front_async()

Brings the app window to the front.

update #

update() -> None

wait_until_ready_to_show #

wait_until_ready_to_show()

Waits until the app window is ready to show.

wait_until_ready_to_show_async #

wait_until_ready_to_show_async()

Waits until the app window is ready to show.

will_unmount #

will_unmount()