Skip to content

Screen

A representation of a screen attached to a device.

Availability (Key)

macOS Linux (GTK) Linux (Qt) Windows iOS Android Web Terminal

Usage

An app will always have access to at least one screen. The toga.App.screens attribute will return the list of all available screens; the screen at index 0 will be the "primary" screen. Screen sizes and positions are given in CSS pixels.

# Print the size of the primary screen.
print(my_app.screens[0].size)

# Print the identifying name of the second screen
print(my_app.screens[1].name)

Notes

  • When using the GTK backend under Wayland, the screen at index 0 may not be the primary screen. This because the separation of concerns enforced by Wayland makes determining the primary screen unreliable.

Reference

toga.screens.Screen

Screen(_impl: Any)

name property

name: str

Unique name of the screen.

origin property

origin: Position

The absolute coordinates of the screen's origin, in CSS pixels.

size property

size: Size

The size of the screen, in CSS pixels.

as_image

as_image(format: type[ImageT] = Image) -> ImageT

Render the current contents of the screen as an image.

PARAMETER DESCRIPTION
format

Format to provide. Defaults to Image; also supports PIL.Image.Image if Pillow is installed, as well as any image types defined by installed image format plugins.

TYPE: type[ImageT] DEFAULT: Image

RETURNS DESCRIPTION
ImageT

An image containing the screen content, in the format requested.