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:
WidgetRoot display surface that owns the framebuffer, event loop, and widget tree.
Create one
Displayper hardware panel and attach it to the app’s sharedappdevcoordinator. 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
Screenfor the active pageadd 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).
- 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_managerbefore the widget tree walk. Pointer modality (seeWidget.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_screentoscreen.
- 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_taskto cancel).
- refresh(area)[source]
Copy a dirty region from the internal framebuffer to the physical display.
- Parameters:
area –
Areaor(x, y, w, h)rectangle to flush.