displaydev.pgdisplay

displaydev.pgdisplay

displaydev.pgdisplay.poll_event()[source]

Non-blocking poll; return one events event or None (not for QUEUE read).

displaydev.pgdisplay.get_events()[source]

Drain the pygame queue; return a list of events or None.

class displaydev.pgdisplay.PGDisplay(width=320, height=240, rotation=0, color_depth=16, title='displaydev', scale=1.0, window_flags=pygame.SHOWN, *, quiet=False)[source]

Bases: FrameRecorderMixin, DesktopDisplay

Emulate an LCD window with pygame-ce (pygame.Window).

Requires pygame-ce with public Window.get_surface / Window.flip (no pygame._sdl2). Provides scrolling and rotation similar to a panel driver; scale is reduced when the window would not fit the desktop work area.

Parameters:
  • width (int, optional) – Panel width in pixels. Defaults to 320.

  • height (int, optional) – Panel height in pixels. Defaults to 240.

  • rotation (int, optional) – Rotation in degrees. Defaults to 0.

  • color_depth (int, optional) – Bits per pixel. Defaults to 16.

  • title (str, optional) – Window title. Defaults to "displaydev".

  • scale (float, optional) – Window scale factor. Defaults to 1.0.

  • window_flags (int, optional) – pygame display flags. Defaults to pg.SHOWN.

  • quiet (bool) – Suppress init chatter when True.

color_depth

Bits per pixel.

Type:

int

touch_scale

Scale used to map host pointer coords into panel space.

Type:

float

needs_refresh

True — appdev.App drives periodic show().

Type:

bool

init()[source]

Initializes the display instance. Called by __init__ and rotation setter.

blit_rect(buffer, x, y, w, h)[source]

Blit a buffer into the logical framebuffer. Compositing is deferred until show().

fill_rect(x, y, w, h, c)[source]

Fill a rectangle in the logical framebuffer. Compositing is deferred until show().

pixel(x, y, c)[source]

Set a pixel on the display.

Parameters:
  • x (int) – The x-coordinate of the pixel.

  • y (int) – The y-coordinate of the pixel.

  • c (int) – The color of the pixel.

Returns:

(tuple) – A tuple containing the x, y, w & h values.

capture_rgb()[source]

Return the visible window as (RGB24 bytes, width, height).

render(renderRect=None)[source]

Composite the logical framebuffer to the window. Called from show() when draws are pending.

show(_timer=None)[source]

Show the display.

quit(code=0, force=False)[source]

Release pygame resources (REPL-safe unless force=True).