pdwidgets
Declarative Hierarchy
Build composable UI trees with Display, Screen, and nested container widgets that handle layout and clipping automatically.
Dirty-Rect Rendering
Efficient frame updates only repaint what changed using pygraphics.Area bounding boxes, maximizing frame rates on embedded SPI panels.
Touch, Keys & Encoders
Unified input handling across touch screens, mouse pointers, rotary encoders, joysticks, and physical keyboards with focus navigation.
Material Theming
Built-in integration with palettes for Material Design color tokens, rounded corner radii, and lightweight compiled icon assets.
π Installation
import mip
# Install pdwidgets and its PyDevices companion packages
mip.install("pydevices", index="https://PyDevices.github.io/mip")
mip.install("pygraphics", index="https://PyDevices.github.io/mip")
mip.install("palettes", index="https://PyDevices.github.io/mip")
mip.install("pdwidgets", index="https://PyDevices.github.io/mip")
The wheel is named pydevices-pdwidgets; the module you import is
pdwidgets. micropip resolves the rest (pydevices,
pydevices-pygraphics, pydevices-palettes) from the wheel metadata.
import micropip
await micropip.install(
"pydevices-pdwidgets", index_urls="https://test.pypi.org/simple/"
)
import pdwidgets as pd
On MicroPython the MIP package names are unprefixed
(mip.install("pdwidgets", index="https://PyDevices.github.io/mip")).
π¨ Live Interactive Demo
Click the interactive button and slider below to interact with pdwidgets live in your browser:
Practical App Skeleton
Every pdwidgets application follows a standard three-stage pattern:
import board_config
import appdev
import pdwidgets as pd
# 1. Initialize Display and Application Controller
app = appdev.App(board_config)
display = pd.Display(board_config.display_drv, app)
screen = pd.Screen(display, bg=0x0000)
# 2. Build UI Hierarchy
label = pd.Label(screen, value="System Ready", x=10, y=10)
button = pd.Button(screen, label="Start", x=10, y=40, radius=4)
def on_click(sender, event):
label.value = "Running!"
button.add_event_cb(pd.events.MOUSEBUTTONUP, on_click)
# 3. That's it -- the app keeps itself alive and handles input from here.
π¨ Featured Interactive Applications
Explore full-featured GUI applications built with pdwidgets:
Pocket Calculator
Tactile raised 3D buttons with full arithmetic engine and real-time display readout.
Clinic Check-In Kiosk
Multi-tab front-desk kiosk with appointment queue, form validation, and confirm dialogs.
Energy Telemetry Panel
Real-time sparkline telemetry charts, analog gauges, and status monitoring dashboard.
Smart Locker Kiosk
PIN entry keypad terminal for secure pickup with numeric buttons and card transitions.
π Documentation Map
- Architecture & Lifecycle β Display hierarchy, dirty rectangle redraws, and event loop integration.
- Widget Catalog β Complete guide and live demos for all 50+ UI components.
- Layout & Sizing β
ALIGNanchors, percentage sizing (pct), and responsive grids. - Input & Events β Touch gestures, mouse clicks, rotary encoders, and keyboard focus rings.
- Theming & Icons β Palette styling, Material Design colors, corner radii, and icon modules.
- App Recipes β Complete blueprints for Calculators, Smartwatches, and Dashboards.
- API Reference β Autogenerated class and method reference.