Class Display
pygame's display (pygame.display) in pygame's spelling: the display of Default,
the process-wide context, so a line-for-line port keeps pygame.display.set_mode(...) as
Display.SetMode(...). Every member forwards to PygameContext.Default.Display
(PygameDisplay, which documents the behaviour in full).
public static class Display
- Inheritance
-
Display
- Inherited Members
Remarks
One window per process through these statics, as pygame's: SetMode(int, int, bool, EnvViewerFactory?, string?) while a window is open replaces it. A game that should run beside another takes a PygameContext of its own (DR-41); the human-mode windows of envs are separate viewers and are not affected either way.
Thread-safe; draw on the surface from the thread that pumps the queue, which is the one that sees it change.
Reference: src_c/display.c (pygame-ce 2.5.8).
Methods
Flip()
pygame.display.flip() on the default context: shows the surface in the window, as it is now (the viewer copies it).
public static void Flip()
Exceptions
- SdlError
Thrown when no mode is set, with pygame's message:
Display mode not set.
GetInit()
pygame.display.get_init() on the default context, read as "a mode is set": whether Flip() has a window to show.
public static bool GetInit()
Returns
GetSurface()
pygame.display.get_surface() on the default context: the display surface, or null when no mode is set.
public static Surface? GetSurface()
Returns
- Surface
The surface; after a resize, a new one of the new size.
Quit()
pygame.quit() for the default context's display: closes the window, forgets the surface and drops every
pending event of EventQueue. Safe to call when nothing is open.
public static void Quit()
SetMode(int, int, bool, EnvViewerFactory?, string?)
pygame.display.set_mode((width, height), flags) on the default context: opens a window of that client size
and returns its black surface, closing a window already open (see SetMode(int, int, bool, EnvViewerFactory?, string?)).
public static Surface SetMode(int width, int height, bool resizable = false, EnvViewerFactory? viewerFactory = null, string? title = null)
Parameters
widthintThe client width in pixels, positive.
heightintThe client height in pixels, positive.
resizableboolWhether the user's resizes reach the surface (
pygame.RESIZABLE); otherwise they are ignored.viewerFactoryEnvViewerFactoryThe window's factory; null reads
Gymnasium.HumanViewerFactory(the default context has no factory of its own).titlestringThe window's title, or null for the viewer's default (pygame's is
pygame window).
Returns
- Surface
The display surface, also GetSurface().
Remarks
An interactive window reports input from here on, so its close button posts Quit instead of closing it until Quit().
Exceptions
- ArgumentOutOfRangeException
Thrown for a size that is not positive (0 would be a desktop-sized window in pygame, not modelled).
- DependencyNotInstalled
Thrown when no factory is given or set, where pygame would be missing.