Skip to main content

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 & Draw Class: Call methods directly on FrameBuffer instances (fb.circle(...)), invoke standalone canvas functions (pygraphics.circle(fb, ...)), or use the Draw styling context for maximum architectural flexibility.
  • Exposed Attributes: Direct read-only access to .buf, .width, .height, .stride, .format, and .color_depth on every FrameBuffer instance.
  • 24-bit True Color (RGB888): Supports 24-bit packed RGB color format (format constant RGB888), ideal for 24-bit displays as well as NeoPixel (WS2812B) and DotStar (APA102) LED matrix arrays.
  • Dirty Area Returns: Drawing operations return an Area(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, and gradient_rect.
  • Multi-Font Engine: Built-in 8x8 (text8), 8x14 (text14), 8x16 (text16), and custom Font support.
  • 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.

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.

Metadata

Release files for pydevices-pygraphics 0.0.37

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pydevices-pygraphics 0.0.37
File Actions
pydevices_pygraphics-0.0.37-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for pydevices_pygraphics-0.0.37-cp314-cp314-win_amd64.whl
pydevices_pygraphics-0.0.37-cp314-cp314-pyemscripten_2026_0_wasm32.whl CPython 3.14 CPython 3.14 PyEmscripten 2026.0+ WebAssembly Details for pydevices_pygraphics-0.0.37-cp314-cp314-pyemscripten_2026_0_wasm32.whl
pydevices_pygraphics-0.0.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pydevices_pygraphics-0.0.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pydevices_pygraphics-0.0.37-cp314-cp314-android_21_x86_64.whl CPython 3.14 CPython 3.14 Android API level 21+ x86-64 Details for pydevices_pygraphics-0.0.37-cp314-cp314-android_21_x86_64.whl
pydevices_pygraphics-0.0.37-cp314-cp314-android_21_arm64_v8a.whl CPython 3.14 CPython 3.14 Android API level 21+ ARM64 v8a Details for pydevices_pygraphics-0.0.37-cp314-cp314-android_21_arm64_v8a.whl
pydevices_pygraphics-0.0.37-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for pydevices_pygraphics-0.0.37-cp313-cp313-win_amd64.whl
pydevices_pygraphics-0.0.37-cp313-cp313-pyemscripten_2025_0_wasm32.whl CPython 3.13 CPython 3.13 PyEmscripten 2025.0+ WebAssembly Details for pydevices_pygraphics-0.0.37-cp313-cp313-pyemscripten_2025_0_wasm32.whl
pydevices_pygraphics-0.0.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for pydevices_pygraphics-0.0.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pydevices_pygraphics-0.0.37-cp313-cp313-android_21_x86_64.whl CPython 3.13 CPython 3.13 Android API level 21+ x86-64 Details for pydevices_pygraphics-0.0.37-cp313-cp313-android_21_x86_64.whl
pydevices_pygraphics-0.0.37-cp313-cp313-android_21_arm64_v8a.whl CPython 3.13 CPython 3.13 Android API level 21+ ARM64 v8a Details for pydevices_pygraphics-0.0.37-cp313-cp313-android_21_arm64_v8a.whl
pydevices_pygraphics-0.0.37-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pydevices_pygraphics-0.0.37-cp312-cp312-win_amd64.whl
pydevices_pygraphics-0.0.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pydevices_pygraphics-0.0.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pydevices_pygraphics-0.0.37-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for pydevices_pygraphics-0.0.37-cp311-cp311-win_amd64.whl
pydevices_pygraphics-0.0.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pydevices_pygraphics-0.0.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pydevices_pygraphics-0.0.37-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for pydevices_pygraphics-0.0.37-cp310-cp310-win_amd64.whl
pydevices_pygraphics-0.0.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pydevices_pygraphics-0.0.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Total release size: 1.8 MB

Release files / pydevices_pygraphics-0.0.37-cp314-cp314-win_amd64.whl

Download URL pydevices_pygraphics-0.0.37-cp314-cp314-win_amd64.whl
Size 57.5 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
a20fd6c21c2a7830739a593c621877fb4cd6b4b73579650da71e59966a55a2ac
BLAKE2b-256 checksum
How to use checksums
c9e5141db30cf712f7600e1274d1fdef6fa07622c63af2a4e14e52243281b0a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp314-cp314-pyemscripten_2026_0_wasm32.whl

Download URL pydevices_pygraphics-0.0.37-cp314-cp314-pyemscripten_2026_0_wasm32.whl
Size 34.8 kB
Tags CPython 3.14 PyEmscripten 2026.0+ WebAssembly
SHA-256 checksum
How to use checksums
bde4e5b06387c27e5f6b625d4adb767f19c9077d37e6e75287a38c1b61562f77
BLAKE2b-256 checksum
How to use checksums
418899a73b80b958953924b3bda80b91a9d9ab482d88e38f03a81c7fb0e26410
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 236.8 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a14b377c98ccfa54f0316c00c82239c71180c710abdfe7c18121c46b29008ffa
BLAKE2b-256 checksum
How to use checksums
0f5a81e270c1ae0364e5844715b20da379cd2e9dd86297d4ca937c1ec875d90b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp314-cp314-android_21_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp314-cp314-android_21_x86_64.whl
Size 65.9 kB
Tags Android API level 21+ x86-64 CPython 3.14
SHA-256 checksum
How to use checksums
feb091d1cb9e2c840de9d845c8c453c7862b4bddd6c9b0d6279328117b8b3ee8
BLAKE2b-256 checksum
How to use checksums
f50550d407fd3ab5ce62a8788575b1bc99568a81395a7586b4b5d1d40309a660
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp314-cp314-android_21_arm64_v8a.whl

Download URL pydevices_pygraphics-0.0.37-cp314-cp314-android_21_arm64_v8a.whl
Size 61.8 kB
Tags Android API level 21+ ARM64 v8a CPython 3.14
SHA-256 checksum
How to use checksums
fb09d63f0aee42fdfdd29e38dd286ff131ae45acaa04d81ed031192c1d873744
BLAKE2b-256 checksum
How to use checksums
4e1022b94c3981f3b145de4631463d7f8a314e9e0a15d0d9eb0a3300ad052a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp313-cp313-win_amd64.whl

Download URL pydevices_pygraphics-0.0.37-cp313-cp313-win_amd64.whl
Size 55.9 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
45c4c52636674627906246701bfaf2bfd0c60dac049d66991d494e9b1c30b9f1
BLAKE2b-256 checksum
How to use checksums
13b73e734227864b81cb1b8751d8e79a7f8fb6566129ccfe87de42256a265050
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp313-cp313-pyemscripten_2025_0_wasm32.whl

Download URL pydevices_pygraphics-0.0.37-cp313-cp313-pyemscripten_2025_0_wasm32.whl
Size 34.9 kB
Tags CPython 3.13 PyEmscripten 2025.0+ WebAssembly
SHA-256 checksum
How to use checksums
657034c6a1a1b4dead43fbd1fa8ea906badb72020c482f2e2949898077f6e1ef
BLAKE2b-256 checksum
How to use checksums
1eec79d6ee3f4e51b18ac61f0cad2992ae7c00d804ffc64e95221d32a69934c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 237.2 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b864fef8f4e2244fd0dc5f25e6bf4e7b0f388ad6d74a6b7b7094b49ac8b1e58e
BLAKE2b-256 checksum
How to use checksums
88bca380cc5284407838ef43ee31381515a4b6b5a4817a3913c8a486396d67b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp313-cp313-android_21_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp313-cp313-android_21_x86_64.whl
Size 65.9 kB
Tags Android API level 21+ x86-64 CPython 3.13
SHA-256 checksum
How to use checksums
c641dc9875702cabc8e9f15c2425ad95eb3b90f408a1872db6bfc818fd959285
BLAKE2b-256 checksum
How to use checksums
3705babd0f9c016d3d7d7b7a1b5a15c0d60d9d04813b16c7b0d18919ac9b02b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp313-cp313-android_21_arm64_v8a.whl

Download URL pydevices_pygraphics-0.0.37-cp313-cp313-android_21_arm64_v8a.whl
Size 61.7 kB
Tags Android API level 21+ ARM64 v8a CPython 3.13
SHA-256 checksum
How to use checksums
0a6bca68e8704e78a6d97873c797514721afeaf8c39a677bf740c12e9aee81e5
BLAKE2b-256 checksum
How to use checksums
7457fff16c9b2fabde6c3b13a3fb535286f67d69469a6532903e4d3700f20a4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp312-cp312-win_amd64.whl

Download URL pydevices_pygraphics-0.0.37-cp312-cp312-win_amd64.whl
Size 55.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
7f9d72d341d6474cf4cd9e387a79d1323e1b28e1eb00755d6aa8c7978ebe317d
BLAKE2b-256 checksum
How to use checksums
48be4ad76645a89bf126cd2c8f03bb77592cd07aff9ad9029b4b04e9d10dfc65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 237.1 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
eb97cba0113556f50ee27ae62b1665c6de44d198c3d50cddc513f263bdda5892
BLAKE2b-256 checksum
How to use checksums
395c7803b7e40c67129955fe5a96abfe25ac46cf577dbcbc432486323a65acd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp311-cp311-win_amd64.whl

Download URL pydevices_pygraphics-0.0.37-cp311-cp311-win_amd64.whl
Size 55.7 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
3e7eb3bdb14f87bda5a239e9fc3567a52226b4c1a7479f81d4cb2c7e0232ee7f
BLAKE2b-256 checksum
How to use checksums
66725f4c5680bd859f473fdc9936219cd379a7a6b37cc8a083a1eeb0a180ebe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 233.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
853e3055dbf651f552b7133e336e3b683d58c5d44092ba182c9ac41195ae900a
BLAKE2b-256 checksum
How to use checksums
4be20a3dc0696ed4e48285a71b6e5666b1bee55ca5ae7fcee42f2cb002ef8b72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp310-cp310-win_amd64.whl

Download URL pydevices_pygraphics-0.0.37-cp310-cp310-win_amd64.whl
Size 55.7 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
0d30d79302e2aa333873391a919f83c79a2ee4a2ec691cb08bf213b523ef4bd5
BLAKE2b-256 checksum
How to use checksums
eac560449b5c6d98a4255b20ecddb0b9f0b379de4b386547d52a8c8a4ff7a633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pydevices_pygraphics-0.0.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pydevices_pygraphics-0.0.37-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 230.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
eb4629ccdf1ac5ed8adf935cea9354d7b202ad5e78875bddc778217806da3f4c
BLAKE2b-256 checksum
How to use checksums
192a5bfd4e82e74591313dba8cec6e3444a26fa518d2514fd251cf0db5ac8171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for pydevices-pygraphics 0.0.37

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.37 This release

16 release files No provenance

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