Screen Class

Inheritance diagram of Screen

class Screen(display, x, y, width, height)

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 arranged above or next to one another.

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

See also

Programming Guide - Screens

Constructor:

__init__(display, x, y, width, height)
Parameters:
  • display (~pyglet.canvas.Display) – display
  • x (int) – Left edge x
  • y (int) – Top edge y
  • width (int) – width
  • height (int) – height

Methods:

get_best_config([template]) Get the best available GL config.
get_closest_mode(width, height) Get the screen mode that best matches a given size.
get_matching_configs(template) Get a list of configs that match a specification.
get_mode() Get the current display mode for this screen.
get_modes() Get a list of screen modes supported by this screen.
restore_mode() Restore the screen mode to the user’s default.
set_mode(mode) Set the display mode for this screen.

Methods

Screen.get_best_config(template=None)

Get the best available GL config.

Any required attributes can be specified in template. If no configuration matches the template, NoSuchConfigException will be raised.

Warning

Deprecated. Use pyglet.gl.Config.match().

Parameters:template (pyglet.gl.Config) – A configuration with desired attributes filled in.
Return type:Config
Returns:A configuration supported by the platform that best fulfils the needs described by the template.
Screen.get_closest_mode(width, height)

Get the screen mode that best matches a given size.

If no supported mode exactly equals the requested size, a larger one is returned; or None if no mode is large enough.

Parameters:
  • width (int) – Requested screen width.
  • height (int) – Requested screen height.
Return type:

ScreenMode

Note

Since pyglet 1.2

Screen.get_matching_configs(template)

Get a list of configs that match a specification.

Any attributes specified in template will have values equal to or greater in each returned config. If no configs satisfy the template, an empty list is returned.

Warning

Deprecated. Use pyglet.gl.Config.match().

Parameters:template (pyglet.gl.Config) – A configuration with desired attributes filled in.
Return type:list of Config
Returns:A list of matching configs.
Screen.get_mode()

Get the current display mode for this screen.

Return type:ScreenMode

Note

Since pyglet 1.2

Screen.get_modes()

Get a list of screen modes supported by this screen.

Return type:list of ScreenMode

Note

Since pyglet 1.2

Screen.restore_mode()

Restore the screen mode to the user’s default.

Screen.set_mode(mode)

Set the display mode for this screen.

The mode must be one previously returned by get_mode() or get_modes().

Parameters:mode (ScreenMode) – Screen mode to switch this screen to.

Table Of Contents

Previous topic

Display Class

Next topic

ScreenMode Class