pygraphics
Native and pure-Python pygraphics for MicroPython, CircuitPython, and CPython.
The C module can be built into MicroPython or CircuitPython, while the pure-Python
package is available for users who prefer not to compile their own build.
Import as pygraphics.
| Product | Pip / MIP | Role |
|---|---|---|
| pygraphics | TestPyPI pydevices-pygraphics |
Native/C-extension wheel for CPython and for embedded builds that include the module (prefer on desktop/Android/Pyodide when available) |
| pygraphics | MIP pygraphics |
Pure-Python package for users who do not want to compile their own build (same public API) |
One release tag vX.Y.Z publishes both products at that version.
Install
# Native C extension (CPython desktop, Android, Pyodide)
pip install -i https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ pydevices-pygraphics
# Pure Python, for MicroPython and CircuitPython
import mip
mip.install("pygraphics", index="https://PyDevices.github.io/mip")
Full options and verification: docs/installation.md.
Quick start
import pygraphics
from pygraphics import FrameBuffer, RGB565
fb = FrameBuffer(bytearray(160 * 128 * 2), 160, 128, RGB565)
fb.fill(0)
fb.fill_rect(10, 10, 40, 40, 0xF800)
print(pygraphics.implementation()) # native_cmod or pygraphics_python
pygraphics has zero external dependencies on any other PyDevices libraries or hardware modules. It functions as an independent, portable 2D graphics engine that can be used in any MicroPython, CircuitPython, or CPython project needing fast drawing primitives or off-screen framebuffer manipulation, regardless of whether you are using PyDevices displays.
pygraphics extends MicroPython's standard framebuf into a powerful 2D graphics engine while preserving full API compatibility:
- Zero Dependencies & Universal Use: No required external packages; usable in any Python application.
- Dual Invocation &
DrawClass: Call methods directly onFrameBufferinstances (fb.circle(...)), invoke standalone canvas functions (pygraphics.circle(fb, ...)), or use theDrawstyling context for maximum architectural flexibility. - Exposed Attributes: Direct read-only access to
.buf,.width,.height,.stride,.format, and.color_depthon everyFrameBufferinstance. - 24-bit True Color (
RGB888): Supports 24-bit packed RGB color format (format constantRGB888), ideal for 24-bit displays as well as NeoPixel (WS2812B) and DotStar (APA102) LED matrix arrays. - Dirty
AreaReturns: Drawing operations return anArea(x, y, w, h)bounding box so drivers can flush only modified screen regions. - Rich Primitive Library: Standard shapes plus
round_rect,circle,arc,triangle,polygon, andgradient_rect. - Multi-Font Engine: Built-in 8x8 (
text8), 8x14 (text14), 8x16 (text16), and customFontsupport. - Image & File I/O: Load and save images directly using
load_image,save_image,export_framebuffer,BMP565, and PBM/PGM codecs. - Colorkey Blitting:
blit_transparent()for transparent sprite overlays. - Native C Speed & Fallback Safety: C acceleration compiled for MicroPython, CircuitPython, and CPython wheels (TestPyPI
pydevices-pygraphics), with a pure-Python fallback available whenever precompiled binaries are not present in the firmware or environment.
Links
License
MIT (framebuf algorithms derived from MicroPython extmod/modframebuf.c, Damien P. George).
Build from source
Layout
pygraphics/
micropython.mk / micropython.cmake / circuitpython.mk / setup.py
src/ # C sources + headers (gfx_*.h, font_8x*.h, qstrs)
lib/pygraphics/ # pure-Python package (import pygraphics)
tests/ # native smoke / parity tests
tools/ # developer benchmarks / helpers
docs/ scripts/ web/
CPython native (editable)
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/python tests/test_area.py
.venv/bin/python tests/test_pygraphics.py
.venv/bin/python tests/test_subclass.py
Pure Python (no extension)
PYTHONPATH=lib python3 -c "import pygraphics; print(pygraphics.implementation())"
Parity testing (native vs pure-Python)
micropython tools/compare_graphics_run.py # single interpreter
python tools/compare_graphics_matrix.py # all desktop interpreters
micropython tools/compare_framebuf_mp.py # C framebuf vs lib/pygraphics/framebuf.py
MicroPython
Clone as a sibling of micropython/:
workspace/
pygraphics/ ← this repo
micropython/
cd micropython/ports/unix
make submodules
make USER_C_MODULES=../../..
cd ../../..
./micropython/ports/unix/build-standard/micropython pygraphics/tests/test_area.py
CircuitPython (unix)
Adafruit’s Extending CircuitPython
guide (and the design guide — native modules)
describe adding shared-bindings/ + shared-module/ inside the CircuitPython
tree. This repo keeps those sources out-of-tree under src/circuitpython_spike/
and applies them with ./apply_cp_patches.sh into a local (uncommitted)
CircuitPython clone — Adafruit has no separate out-of-tree C-module path.
| Adafruit step | This repo |
|---|---|
shared-bindings/<mod>/ |
src/circuitpython_spike/shared-bindings/pygraphics/ |
shared-module/<mod>/ |
src/circuitpython_spike/shared-module/pygraphics/ |
Enable CIRCUITPY_* |
Patches set CIRCUITPY_PYGRAPHICS |
| List sources in port Makefile | Variant .mk + SRC_PATTERNS |
| Build | make after --apply |
Clone as a sibling of circuitpython/:
# siblings: circuitpython/ and pygraphics/
./apply_cp_patches.sh --apply
cd ../circuitpython/ports/unix && make -j VARIANT=coverage
See the cmods workspace for an easier way to build this repo with other user C modules (MicroPython) or extensions (CircuitPython).
pydevices-examples integration
When this cmod is installed or linked, pygraphics.framebuf_backend() reports
native and pygraphics.implementation() reports native_cmod. Otherwise the
pure-Python package reports pygraphics_python.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydevices_pygraphics-0.0.37-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 57.5 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a20fd6c21c2a7830739a593c621877fb4cd6b4b73579650da71e59966a55a2ac
|
|
| MD5 |
6910c6265847be24e7b4163bce97f3a2
|
|
| BLAKE2b-256 |
c9e5141db30cf712f7600e1274d1fdef6fa07622c63af2a4e14e52243281b0a1
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp314-cp314-pyemscripten_2026_0_wasm32.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp314-cp314-pyemscripten_2026_0_wasm32.whl
- Upload date:
- Size: 34.8 kB
- Tags: CPython 3.14, PyEmscripten 2026.0 wasm32
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde4e5b06387c27e5f6b625d4adb767f19c9077d37e6e75287a38c1b61562f77
|
|
| MD5 |
9b5c990075dae70c21bdef1e85c023c3
|
|
| BLAKE2b-256 |
418899a73b80b958953924b3bda80b91a9d9ab482d88e38f03a81c7fb0e26410
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 236.8 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a14b377c98ccfa54f0316c00c82239c71180c710abdfe7c18121c46b29008ffa
|
|
| MD5 |
4c2014ddbb78143ea9b82bd3f3dc34de
|
|
| BLAKE2b-256 |
0f5a81e270c1ae0364e5844715b20da379cd2e9dd86297d4ca937c1ec875d90b
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp314-cp314-android_21_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp314-cp314-android_21_x86_64.whl
- Upload date:
- Size: 65.9 kB
- Tags: Android API level 21+ x86-64, CPython 3.14
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feb091d1cb9e2c840de9d845c8c453c7862b4bddd6c9b0d6279328117b8b3ee8
|
|
| MD5 |
1bbcf3c024d2613a4df895f3c1e1a2d1
|
|
| BLAKE2b-256 |
f50550d407fd3ab5ce62a8788575b1bc99568a81395a7586b4b5d1d40309a660
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp314-cp314-android_21_arm64_v8a.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp314-cp314-android_21_arm64_v8a.whl
- Upload date:
- Size: 61.8 kB
- Tags: Android API level 21+ ARM64 v8a, CPython 3.14
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb09d63f0aee42fdfdd29e38dd286ff131ae45acaa04d81ed031192c1d873744
|
|
| MD5 |
7fb49578e8866c5e90988bc9641b26ac
|
|
| BLAKE2b-256 |
4e1022b94c3981f3b145de4631463d7f8a314e9e0a15d0d9eb0a3300ad052a65
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 55.9 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45c4c52636674627906246701bfaf2bfd0c60dac049d66991d494e9b1c30b9f1
|
|
| MD5 |
d7a513d2e3f71a81d2d19bda7ee19d32
|
|
| BLAKE2b-256 |
13b73e734227864b81cb1b8751d8e79a7f8fb6566129ccfe87de42256a265050
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp313-cp313-pyemscripten_2025_0_wasm32.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp313-cp313-pyemscripten_2025_0_wasm32.whl
- Upload date:
- Size: 34.9 kB
- Tags: CPython 3.13, PyEmscripten 2025.0 wasm32
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
657034c6a1a1b4dead43fbd1fa8ea906badb72020c482f2e2949898077f6e1ef
|
|
| MD5 |
11d3824567e7c84701346fa2bda8ea1d
|
|
| BLAKE2b-256 |
1eec79d6ee3f4e51b18ac61f0cad2992ae7c00d804ffc64e95221d32a69934c0
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 237.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b864fef8f4e2244fd0dc5f25e6bf4e7b0f388ad6d74a6b7b7094b49ac8b1e58e
|
|
| MD5 |
71793ef2656f6944e2848efdd5d0dd40
|
|
| BLAKE2b-256 |
88bca380cc5284407838ef43ee31381515a4b6b5a4817a3913c8a486396d67b4
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp313-cp313-android_21_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp313-cp313-android_21_x86_64.whl
- Upload date:
- Size: 65.9 kB
- Tags: Android API level 21+ x86-64, CPython 3.13
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c641dc9875702cabc8e9f15c2425ad95eb3b90f408a1872db6bfc818fd959285
|
|
| MD5 |
f049d00e4de2f4fcada4e0980b2bc69a
|
|
| BLAKE2b-256 |
3705babd0f9c016d3d7d7b7a1b5a15c0d60d9d04813b16c7b0d18919ac9b02b3
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp313-cp313-android_21_arm64_v8a.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp313-cp313-android_21_arm64_v8a.whl
- Upload date:
- Size: 61.7 kB
- Tags: Android API level 21+ ARM64 v8a, CPython 3.13
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a6bca68e8704e78a6d97873c797514721afeaf8c39a677bf740c12e9aee81e5
|
|
| MD5 |
3fc9137bb31322adf9d71135ce34ea37
|
|
| BLAKE2b-256 |
7457fff16c9b2fabde6c3b13a3fb535286f67d69469a6532903e4d3700f20a4b
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 55.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f9d72d341d6474cf4cd9e387a79d1323e1b28e1eb00755d6aa8c7978ebe317d
|
|
| MD5 |
0ccc557fc4f39846cd5c5f943160bd6b
|
|
| BLAKE2b-256 |
48be4ad76645a89bf126cd2c8f03bb77592cd07aff9ad9029b4b04e9d10dfc65
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 237.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb97cba0113556f50ee27ae62b1665c6de44d198c3d50cddc513f263bdda5892
|
|
| MD5 |
acfd264b4694dc54a6705408a70b57fb
|
|
| BLAKE2b-256 |
395c7803b7e40c67129955fe5a96abfe25ac46cf577dbcbc432486323a65acd2
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 55.7 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e7eb3bdb14f87bda5a239e9fc3567a52226b4c1a7479f81d4cb2c7e0232ee7f
|
|
| MD5 |
7030839bf5776982a45651ed89f7750e
|
|
| BLAKE2b-256 |
66725f4c5680bd859f473fdc9936219cd379a7a6b37cc8a083a1eeb0a180ebe9
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 233.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
853e3055dbf651f552b7133e336e3b683d58c5d44092ba182c9ac41195ae900a
|
|
| MD5 |
efab35371bfe6a68d7b69b6c1af513aa
|
|
| BLAKE2b-256 |
4be20a3dc0696ed4e48285a71b6e5666b1bee55ca5ae7fcee42f2cb002ef8b72
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 55.7 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d30d79302e2aa333873391a919f83c79a2ee4a2ec691cb08bf213b523ef4bd5
|
|
| MD5 |
82294358bc9d4732b7e8dad2e58bec1e
|
|
| BLAKE2b-256 |
eac560449b5c6d98a4255b20ecddb0b9f0b379de4b386547d52a8c8a4ff7a633
|
File details
Details for the file pydevices_pygraphics-0.0.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pydevices_pygraphics-0.0.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 230.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb4629ccdf1ac5ed8adf935cea9354d7b202ad5e78875bddc778217806da3f4c
|
|
| MD5 |
92e45bf242ddfe9b2b0ab64dd1ff2144
|
|
| BLAKE2b-256 |
192a5bfd4e82e74591313dba8cec6e3444a26fa518d2514fd251cf0db5ac8171
|