pyglet.display

Display and screen management.

Rendering is performed on the content area of a pyglet.window.Window, or an entire screen.

Windows must belong to a Display. On Microsoft Windows and macOS, there is only one display, which can be obtained with get_display(). Linux supports multiple displays, corresponding to discrete X11 display connections and screens. get_display() on Linux returns the default display and screen 0 (localhost:0.0); if a particular screen or display is required then Display can be instantiated directly.

Within a display one or more screens are attached. A Screen often corresponds to a physical attached monitor, however a monitor or projector set up to clone another screen will not be listed. Use Display.get_screens() to get a list of the attached screens; these can then be queried for their sizes and virtual positions on the desktop.

The size of a screen is determined by its current mode, which can be changed by the application; see the documentation for Screen.

Added in version 1.2.

class Canvas

Abstract drawing area.

Canvases are used internally by pyglet to represent drawing areas – either within a window or full-screen.

Added in version 1.2.

display

Display this canvas was created on.

class Display

A display device supporting one or more screens.

name: str = None

Name of this display, if applicable.

x_screen: int = None

The X11 screen number of this display, if applicable.

class Screen

A virtual monitor that supports fullscreen windows.

Screens typically map onto a physical display such as a monitor, television or projector. Selecting a screen for a window has no effect unless the window is made fullscreen, in which case the window will fill only that particular virtual screen.

The width and height attributes of a screen give the current resolution of the screen. The x and y attributes give the global location of the top-left corner of the screen. This is useful for determining if screens are arranged above or next to one another.

Use get_screens() or get_default_screen() to obtain an instance of this class.

get_dpi()

Get the DPI of the screen.

display

Display this screen belongs to.

height

Height of the screen, in pixels.

width

Width of the screen, in pixels.

x

Left edge of the screen on the virtual desktop.

y

Top edge of the screen on the virtual desktop.

class ScreenMode

Screen resolution and display settings.

Applications should not construct ScreenMode instances themselves; see Screen.get_modes().

The depth and rate variables may be None if the operating system does not provide relevant data.

Added in version 1.2.

depth: int = None

Pixel color depth, in bits per pixel.

height: int = None

Height of screen, in pixels.

rate: int = None

Screen refresh rate in Hz.

width: int = None

Width of screen, in pixels.

class Display

A display device supporting one or more screens.

name: str = None

Name of this display, if applicable.

x_screen: int = None

The X11 screen number of this display, if applicable.

class Screen

A virtual monitor that supports fullscreen windows.

Screens typically map onto a physical display such as a monitor, television or projector. Selecting a screen for a window has no effect unless the window is made fullscreen, in which case the window will fill only that particular virtual screen.

The width and height attributes of a screen give the current resolution of the screen. The x and y attributes give the global location of the top-left corner of the screen. This is useful for determining if screens are arranged above or next to one another.

Use get_screens() or get_default_screen() to obtain an instance of this class.

get_dpi()

Get the DPI of the screen.

display

Display this screen belongs to.

height

Height of the screen, in pixels.

width

Width of the screen, in pixels.

x

Left edge of the screen on the virtual desktop.

y

Top edge of the screen on the virtual desktop.

class Canvas

Abstract drawing area.

Canvases are used internally by pyglet to represent drawing areas – either within a window or full-screen.

Added in version 1.2.

display

Display this canvas was created on.