pdwidgets.display

Display framebuffer, rendering, and app integration.

pdwidgets.display.getrandbits(k) → x.  Generates an int with k random bits.
class pdwidgets.display.Display(display_drv, app, tfa=0, bfa=0, format=pygraphics.RGB565)[source]

Bases: Widget

Root display surface that owns the framebuffer, event loop, and widget tree.

Create one Display per hardware panel and attach it to the app’s shared appdev coordinator. The display becomes the root of the widget hierarchy, and its render loop is driven by the app’s timer callback so widgets redraw without a separate timer of their own.

Typical setup:

  • build a Screen for the active page

  • add child widgets with relative geometry and alignment

  • nothing else: the app drives input handling and rendering itself once construction is done

property parent

Always None; the display is the root.

property x

Display x offset (always 0).

property y

Display y offset (always 0).

property width

Framebuffer width in pixels.

property height

Framebuffer height in pixels.

property display

Return self.

property color_theme

Semantic color theme for this display.

property visible

Always True.

clip_push(area)[source]

Push an integer clip rectangle for nested draw/render (MCU-safe, no alpha).

clip_pop()[source]

Pop the current clip rectangle and restore the previous draw target.

handle_event(event, condition=None, point=None)[source]

Dispatch an event, honoring modal pointer capture and focus keys.

Focus keys (Tab / Shift-Tab / arrows) are handled by focus_manager before the widget tree walk. Pointer modality (see Widget.set_modal) only affects mouse/touch — key focus is independent so sheets/dialogs can still host TextInput fields.

property active_screen

The currently attached Screen, if any.

add_child(screen)[source]

Set active_screen to screen.

set_position(*args, **kwargs)[source]

Reset geometry to the full display size.

add_task(callback, delay)[source]

Schedule a repeating task run from tick.

Parameters:
  • callback (callable) – Zero-argument callable to run.

  • delay (int) – Interval between runs, in milliseconds.

Returns:

Task – The created task (pass to remove_task to cancel).

refresh(area)[source]

Copy a dirty region from the internal framebuffer to the physical display.

Parameters:

area – Area or (x, y, w, h) rectangle to flush.

remove_task(task)[source]

Cancel a scheduled task.

Parameters:

task (Task) – A task previously returned by add_task.

quit()[source]

Remove this display from the active list (called on QUIT).

deinit()[source]

Detach display from active list, cancel timers, and unsubscribe events.

tick()[source]

Render one widget frame.

Flushes dirty areas to the display, otherwise runs scheduled tasks and re-renders invalidated widgets. Driven automatically by the app’s shared timer (see _attach_to_app); may also be called manually (e.g. tick) to force a frame.

render_dirty_widgets()[source]

Redraw all invalidated widgets, breadth-first, without recursion.

pdwidgets.display.tick(_=None)[source]

Call the tick method of every registered Display.

Parameters:

_ (Any) – Ignored positional argument so this may also be used as a timer/on_tick callback signature.