Skip to main content

pdwidgets

Pure-Python, portable widget toolkit for PyDevices

pdwidgets provides a complete, 100% pure-Python GUI toolkit for building touchscreen and desktop interfaces without requiring native C bindings or complex build toolchains. It runs seamlessly on MicroPython, CircuitPython, CPython desktop, and PyScript (Web).

Where pdwidgets fits

PyDevices offers several GUI approaches; pdwidgets is the pure-Python one. See pydevices — choosing a GUI layer.


Quick Start: Interactive Button & Screen

import board_config
import appdev
import pdwidgets as pd
from pdwidgets.icons import touch_app  # Pure-Python icon bytecode

# 1. Initialize display and the event app
app = appdev.App(board_config)
display = pd.Display(board_config.display_drv, app)
screen = pd.Screen(display)

_taps = 0

# 2. Add an interactive button with a click handler
btn = pd.Button(
    screen,
    x=40,
    y=60,
    w=160,
    h=50,
    label="Tap me (0)",
    icon=touch_app,
)

def on_button_click(event):
    global _taps
    _taps += 1
    btn.set_label(f"Tap me ({_taps})")
    display.refresh()

btn.on_click(on_button_click)

# 3. Draw the initial screen. The app runs itself from here -- no app.run()
# is needed; call it only to block at this point or to get an exit code.
display.show(screen)

Key Features

  • 100% Pure Python & Portable: Zero native C extensions or compilation steps required.
  • Zero-File Icon System (pdwidgets.icons): Material Design icons packaged directly as importable Python bytecode modules (bytearray bitmaps)—no SD card assets, binary file I/O, or asset path management needed.
  • MCU Memory-Friendly (Lean Imports): Import individual widgets to minimize RAM footprint on microcontrollers:
    from pdwidgets.widgets.button import Button
    from pdwidgets.widgets.screen import Screen
    
  • Integrated Theming: Customizable color schemes, border radii, and visual states using palettes.

Installation

import mip
# pdwidgets does not pull its dependencies on MIP -- install them too.
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")
pip install -i https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ pydevices-pdwidgets

Full dependency chain and board_config requirements: docs/index.md.

Links & Demos

License

MIT — see LICENSE.


Icon assets (maintainers)

Runtime icons are importable Python modules under lib/pdwidgets/icons/ (no binary mip). Authoring:

# 1) Optional: regenerate mono .pbm / color .bmp from Material Design
.venv/bin/python scripts/assets_generate_pdwidgets_icons.py
.venv/bin/python scripts/assets_make_color_icons.py
# 2) Convert binaries → .py modules (BITMAP = bytearray; uses sibling or TestPyPI pygraphics)
.venv/bin/python scripts/assets_icons_to_py.py --delete-binaries
# Optional bulk dump into assets/icons/
.venv/bin/python scripts/assets_convert_md_png_to_pbm.py
# PNG smoke probe (PyDevices display stack + material-design-icons png/)
SDL_VIDEODRIVER=dummy ../pydevices-examples/.venv/bin/python tools/png_test.py

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydevices_pdwidgets-0.0.22.tar.gz (84.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydevices_pdwidgets-0.0.22-py3-none-any.whl (135.1 kB view details)

Uploaded Python 3

File details

Details for the file pydevices_pdwidgets-0.0.22.tar.gz.

File metadata

  • Download URL: pydevices_pdwidgets-0.0.22.tar.gz
  • Upload date:
  • Size: 84.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for pydevices_pdwidgets-0.0.22.tar.gz
Algorithm Hash digest
SHA256 a9177628fba3551297d1293654a69698ff034564595d0ebfaf3499fd77649167
MD5 69a24393114b1644105ee8b8c43bb51c
BLAKE2b-256 e76017fbd0b94d00f3a7ca7cf72e0d52b4bbc313057ddc8325e32d97df710b92

See more details on using hashes here.

File details

Details for the file pydevices_pdwidgets-0.0.22-py3-none-any.whl.

File metadata

File hashes

Hashes for pydevices_pdwidgets-0.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 1108c8d4f5ddbcd4ff0427f1651c6986753128b4338b3a1e261b845774d6aad3
MD5 2449341df1ae49c24bf8136b1ad2622a
BLAKE2b-256 426bc492ac92c69f3504a473da81d1f7a0126c415973f3d2d18fdaf2f8a522ef

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.22 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page