🎨 Examples catalog

August 12, 2026 · View on GitHub

All examples live in lib/examples/.

mip.install("github:PyDevices/pydevices-examples/packages/examples.json", target="./examples")

Preferred: set PYTHONPATH/MICROPYPATH to .:lib:utils, cd lib, then run python3 examples/<name>.py (or from examples import <name> at the REPL) — see full clone.

!!! tip "Start here" New to pydevices-examples? Copy the App starter boilerplate to begin your first app, then read the pydevices_demo guide for rotation, scrolling, and buffered text.

Every example entry point under lib/examples/ is included in the browser gallery by default (scripts/gallery_generator.py):

EntryKind
examples/<name>.pymodule (?modules=)
examples/<name>/<name>.pypackage manifest (?manifests=)
examples/<name>/__init__.pypackage manifest (if no <name>.py)

Optional header comments (first 10 lines), one line per namespace:

# deps: palettes, lvgl
# modules: calc_engine
# manifests: alien
# gallery: featured
MarkerEffect
# deps: …Logical packages → ?deps= via url_maker (MIP on MicroPython, micropip on Pyodide)
# modules: …Extra example .py stems from this site
# manifests: …Extra site-served packages/<name>.json demo bundles
# gallery: featuredPin to the top of the gallery (badge)
# gallery: skipOmit from the card grid
# gallery: binariesOmit (needs non-mip assets)

Hinch GUI demos need no package header — fetch_ph_gui installs via color/hardware/touch setup.

rg '^# gallery:' lib/examples/
rg '^# deps:' lib/examples/
rg '^# modules:' lib/examples/
rg '^# manifests:' lib/examples/

See PyScript local development.

Canonical patterns

runtime.run_forever() with callbacks — hello.py, scroll.py, pydevices_demo.py, calc_graphics.py:

from board_config import display_drv
from app_runtime import runtime

def on_click(e):
    ...

runtime.on(runtime.events.MOUSEBUTTONDOWN, on_click)
runtime.run_forever()

Event-driven poll — eventsys_encoder_test.py:

display_drv.show()  # after initial draw
while True:
    if elist := runtime.poll():
        for e in elist:
            ...  # draw on event
            display_drv.show()

Forever LVGL / library-driven app — lv_test_timer.py: build UI then runtime.run_forever(). Kit mode keeps a small sync/async wait for LVGL click injection.

tft_config animation / one-shot — subdirectory demos alien/alien.py, tiny_toasters/tiny_toasters.py, chango/chango.py:

from app_runtime import runtime

tft.show()
runtime.run_forever()

LVGL apps — lv_test_timer.py: import display_driver, build UI, then runtime.run_forever(). See LVGL guide.

pdwidgets — widgets_clinic_queue.py and related kiosk demos: build UI, then:

import board_config
import pdwidgets as pd
from app_runtime import runtime

display = pd.Display(board_config.display_drv, runtime)
# ... widgets ...
runtime.run_forever()

Display wires into the runtime at construction. During setup bursts before run_forever(), call pd.tick() to flush draws. See pdwidgets.

Notes

  • font_simpletest.py — cycles string_blit → per_pixel → displaybuf in one run (see Font rendering patterns).
  • nano_gui_simpletest.py / micro_gui_simpletest.py / touch_gui_simpletest.py need the matching Peter Hinch gui/ in utils/ (via fetch_ph_gui / mip). Legend: Platforms = CPython · MCU · PyScript · Wokwi · Packages = core · utils · LVGL

Suggested learning order

StepScriptPlatformsPackagesScreenshot
0App starter (doc boilerplate)CPython · MCU · PyScriptcore—
1pydevices_demo.pyCPython · MCUcore—
2color_test.pyCPython · MCUcorecolor_test
3eventsys_simpletest.pyCPython · MCU · PyScriptcore—
4framebuf_simpletest.pyCPython · MCUcoreframebuf
5graphics_simpletest.pyCPython · MCUcore—
6eventsys_touch_test.pyCPython · MCUcore—
7calc_graphics.pyCPython · PyScriptcore—
8paint.pyCPython · PyScriptcorepaint
9widgets_clinic_queue.pyCPython · MCUutils—

PyScript requires asyncio — see PyScript asyncio guide.

Hello and basics

ResourceDescriptionPlatformsPackages
App starterCopy-paste app boilerplate (doc only)CPython · MCU · PyScriptcore
pydevices_demo.pyClicks, rotation, scroll (runtime.run_forever)CPython · MCU · PyScriptcore
hello.pyMinimal text (tft_config)CPython · MCU · Wokwicore
color_test.pyColor barsCPython · MCUcore
logo.pyLogo drawingCPython · MCUcore
displaysys_block_test.pyBlock transfer testCPython · MCUcore
displaysys_fill_rect_test.pyFill rect testCPython · MCUcore

Events and input

ScriptDescriptionPlatformsPackages
eventsys_simpletest.pyEvent loop basicsCPython · MCU · PyScriptcore
eventsys_touch_test.pyTouch eventsCPython · MCUcore
eventsys_encoder_test.pyRotary encoderMCUcore
scroll_touch_test.pyTouch scrolling (cycles display_drv ↔ DisplayBuffer)CPython · MCUutils
joystick_list_select.pyJoystick + listCPython · MCUcore
keypins_simpletest.pyKeypad pinsMCUutils

Drawing and fonts

ScriptDescriptionPlatformsPackages
framebuf_simpletest.pyframebuf APICPython · MCUcore
graphics_simpletest.pypygraphics moduleCPython · MCUcore
font_simpletest.pyFont: cycles string_blit / per_pixel / displaybufCPython · MCUutils
font_list.pyList / preview .bin fonts from a directoryCPython · MCUcore
fonts.pyPage through fontsCPython · MCUcore
boxlines.pyLines and boxesCPython · MCUcore
bouncing_balls.pyColored balls animationCPython · MCU · PyScriptcore

Bitmaps and palettes

ScriptDescriptionPlatformsPackages
bmp565_simpletest.pyBMP565 load/draw (slice + full blit)CPython · MCUpygraphics
bmp565_sprite.pySprite animationCPython · MCUpygraphics
bmp565_sprite_transparent.pyTransparencyCPython · MCUpygraphics
bmp565_scroll.pyScrolling bitmapCPython · MCUpygraphics
bmp565_scroll_sprite.pyScrolling spriteCPython · MCUpygraphics
palettes_demo.pyPalettes: cycles wheel / cube / materialCPython · MCUcore
pbm_simpletest.pyPBM imagesCPython · MCUcore

Widgets and apps

ScriptDescriptionPlatformsPackages
calc_graphics.pyPocket calculator (pygraphics)CPython · MCU · PyScriptcore
calc_widgets.pyPocket calculator (pdwidgets)CPython · MCU · PyScriptutils
calc_lvgl.pyPocket calculator (LVGL)CPython · MCU · PyScriptLVGL
paint.pyPaint appCPython · PyScriptcore
testris.pyTetris-like gameCPython · MCUcore
apollo.pyApollo DSKYCPython · PyScriptcore
widgets_*.pypdwidgets demosCPython · MCUutils
console_simpletest.pyConsole add-onCPython · MCUutils
console_advanced_demo.pyAdvanced consoleCPython · MCUutils

Display buffers and misc

ScriptDescriptionPlatformsPackages
displaybuf_simpletest.pyDisplayBufferCPython · MCUutils
scroll.pyScrolling textCPython · MCUcore
rotations.pyDisplay rotationCPython · MCUcore
nano_gui_simpletest.pyNano-GUI hardware checkCPython · MCU · PyScriptutils + micropython-nano-gui
micro_gui_simpletest.pyMicro-GUI smokeCPython · MCU · PyScriptutils + micropython-micro-gui
touch_gui_simpletest.pyTouch GUI smokeCPython · MCU · PyScriptutils + micropython-touch
lv_test_timer.pyLVGL timer (follows runtime.timer_async)CPython · MCU · PyScriptLVGL

Subdirectories

Runnable demos in subfolders use the same entry rules (<name>/<name>.py or __init__.py) and optional # pyscript skip: / featured / modules: headers.

DirectoryScriptPlatformsNotes
alien/alien.pyCPython · MP · MCUSprite bounce; runtime.poll() quit each frame
chango/chango.pyCPython · MP · MCU · PyScriptOne-shot font demo; runtime.poll() after draws
noto_fonts/noto_fonts.pyMP · MCU · PyScriptOne-shot Noto font demo; same tail as chango
proverbs/proverbs.pyCPython · MP · MCUChinese proverb slideshow; quit via runtime.poll()
tiny_toasters/tiny_toasters.pyCPython · MP · MCUSprite animation; quit via runtime.poll()
apollo/apollo.pyCPython · PyScriptDSKY emulator (dsky.py + BMP assets)
assets/——Shared fonts and images

Screenshots and live demos

See Try pydevices-examples for the full gallery and browser/Wokwi demos.