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.
Properties
Section titled “Properties”is_minimized
Section titled “is_minimized”is_minimized: boolRead-only property that holds the minimize state of the Window.
is_maximized
Section titled “is_maximized”is_maximized: boolRead-only property that holds the maximize state of the Window.
is_fullscreen
Section titled “is_fullscreen”is_fullscreen: boolRead-only property that returns True if the window is shown fullscreen.
size: PhysicalSizeRead-only property that returns the size of the Window in physical pixels, as a tuple of width and height.
position
Section titled “position”position: PhysicalPositionRead-only property that returns the position of the Window on the screen in physical pixels, as a tuple of x and y.
root_element
Section titled “root_element”root_element: ElementRead-only property that returns the Window’s root element.
Methods
Section titled “Methods”query_descendants
Section titled “query_descendants”query_descendants() -> ElementQueryCreates 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
Section titled “find_elements_by_id”find_elements_by_id(id: str) -> list[Element]grab_window_as_png
Section titled “grab_window_as_png”grab_window_as_png() -> bytesGrabs a screenshot of the window and returns it as a PNG-encoded image.
grab_window_with_mime_type
Section titled “grab_window_with_mime_type”grab_window_with_mime_type(image_mime_type: str) -> bytesGrabs 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.
dispatch_event
Section titled “dispatch_event”dispatch_event(event: PointerPressEvent | PointerReleaseEvent | PointerMoveEvent | PointerScrolledEvent | PointerExitedEvent | KeyPressedEvent | KeyPressRepeatedEvent | KeyReleasedEvent)Dispatches one of the possible event types to the window. Use this for low-level control to simulate user input.
drag_and_drop
Section titled “drag_and_drop”drag_and_drop(start: LogicalPosition, end: LogicalPosition, button: PointerEventButton = PointerEventButton.Left, steps: int = 10) -> NoneSimulates 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
startandend. 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