Skip to content

Window

Window represents a weak reference to a slint::Window in your application.

Use the properties to inspect the window state and use root_element in combination with query_descendants to locate UI elements.

Reading a property or calling a function on a window that no longer exists raises RequestError.

is_minimized: bool

Read-only property that holds the minimize state of the Window.

is_maximized: bool

Read-only property that holds the maximize state of the Window.

is_fullscreen: bool

Read-only property that returns True if the window is shown fullscreen.

Read-only property that returns the size of the Window in physical pixels, as a tuple of width and height.

Read-only property that returns the position of the Window on the screen in physical pixels, as a tuple of x and y.

root_element: Element

Read-only property that returns the Window’s root element.

query_descendants() -> ElementQuery

Creates a new element query into all elements of this window. Unlike window.root_element.query_descendants(), the query looks up the window’s root element each time it runs, so a tracking query keeps working when the window’s contents are replaced.

find_elements_by_id(id: str) -> list[Element]
grab_window_as_png() -> bytes

Grabs a screenshot of the window and returns it as a PNG-encoded image.

grab_window_with_mime_type(image_mime_type: str) -> bytes

Grabs a screenshot of the window and returns it as an image encoded in the supplied format. For this to succeed, build your application with support for that image format enabled in Slint.

For Rust applications, image/png and image/jpeg are enabled by default. Additional formats can be enabled through the image crate ↗ as well as the image-default-formats ↗ feature flag.

For C++, JavaScript, and Python applications, by default image/bmp, image/gif, image/vnd.radiance, image/x-icon, image/jpeg, image/x-exr, image/png, image/x-portable-bitmap, image/x-qoi, image/x-targa, image/tiff, and image/webp are supported.

Dispatches one of the possible event types to the window. Use this for low-level control to simulate user input.

drag_and_drop(start: LogicalPosition, end: LogicalPosition, button: PointerEventButton = PointerEventButton.Left, steps: int = 10) -> None

Simulates a drag-and-drop interaction by dispatching a pointer press at start, a sequence of steps interpolated pointer moves ending at end, and finally a pointer release at end.

Use steps to control granularity of the motion. The last move event lands exactly on end so handlers that read the pointer position on release see the expected location.

  • start: Start position in logical pixels.
  • end: End position in logical pixels.
  • button: The button to press during the drag. Defaults to the left button.
  • steps: Number of interpolated pointer move events between start and end. Must be at least 1.

Raises ValueError if steps is less than 1. If a pointer move fails, the button is released where the pointer got to before the error is raised, so that it isn’t left held down.


© 2026 SixtyFPS GmbH