Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Black PyGame + Blinka

Info

Blinka makes her debut on the big screen! With this library you can use CircuitPython displayio code on PC and Raspberry Pi to output to a PyGame window instead of a hardware display connected to I2C or SPI. This makes it easy to to use displayio elements on HDMI and other large format screens.

Warning: you must check display.check_quit() in the main loop and break if it’s true in order to correctly handle the close button!

Auto Refresh

Auto refresh works differently for this library than for native CircuitPython implementations due to technical limitations of Pygame.

Pygame does not support updating the UI and refreshing the display from a background thread but this is how CircuitPython implements it. To work around this limitation, the library tells the main thread to refresh the display on the next occasion. This happens whenever you call display.check_quit().

To keep your UI responsive, make sure to

  • call display.check_quit() on a regular basis

  • do lengthy processing (e.g. fetching data from the net) in a separate thread. This thread should only update data, but not any UI elements (e.g. labels).

If you disable auto-refresh, the display will still refresh on certain externally triggered events from the window-manager of your OS. This includes events like maximizing a window, moving it, uncovering it and so on. Failing to react to these events might make the window-manager angry and you will be asked what to do with the unresponsive window.

Dependencies

This driver depends on:

Please ensure all dependencies are available they can be installed with pip3

Optional Dependencies

This driver can optionally make use of these displayio module libraries:

They can be installed with pip3.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install blinka-displayio-pygamedisplay

To install system-wide (this may be required in some cases):

sudo pip3 install blinka-displayio-pygamedisplay

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install blinka-displayio-pygamedisplay

Usage Example

import displayio
from blinka_displayio_pygamedisplay import PyGameDisplay

display = PyGameDisplay(width=320, height=240)
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

while True:
    if display.check_quit():
        break

Initialization Parameters

  • width (required) - The width of the window. A value of zero maximizes the window

  • height (required) - The height of the window. A value of zero maximizes the window

  • icon (optional) - An icon for the PyGame window

  • caption (optional) - A caption for the PyGame window

  • native_frames_per_second (optional) - High values result in high CPU load

  • hw_accel (optional) - Whether to use hardware acceleration. Default is True

  • flags (optional) - Pygame display flags, e.g. pygame.FULLSCREEN or pygame.NOFRAME

If you encounter GL or EGL Pygame errors, try setting hw_accel to False to disable hardware acceleration. Performance may be reduced.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

For information on building library documentation, please check out this guide.

Metadata

Release files for blinka-displayio-pygamedisplay 4.0.1

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

Source distribution (sdist)

Source distribution for blinka-displayio-pygamedisplay 4.0.1
File Size Uploaded
blinka_displayio_pygamedisplay-4.0.1.tar.gz 238.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blinka-displayio-pygamedisplay 4.0.1
File Interpreter ABI Platform
blinka_displayio_pygamedisplay-4.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 247.1 kB

Release files / blinka_displayio_pygamedisplay-4.0.1.tar.gz

Download URL blinka_displayio_pygamedisplay-4.0.1.tar.gz
Size 238.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5ee9ade9958d22715bd698fee52175da165d4d69022840e04f12c46d2d9e0647
BLAKE2b-256 checksum
How to use checksums
99fec7ddf11ce0549fd33741253c2257d13e0b56905099411877783b60f74047
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / blinka_displayio_pygamedisplay-4.0.1-py3-none-any.whl

Download URL blinka_displayio_pygamedisplay-4.0.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c475bb600c611262cb887c34b4533ddf5bce5bcbe8a03c7ed22e1f082a682ab5
BLAKE2b-256 checksum
How to use checksums
b28531253d8b8555c613222ccc0906bac2618f5f7b28a481a037a755a9b2d89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

4.0.1 This release

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

1.0.0

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

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