A pygame API-compatible reimplementation for running `pygame`-style code inside Jupyter notebooks (backed by ipycanvas).
Project description
ipygame
ipygame is a pygame-style API for writing small games inside Jupyter notebooks, primarily for teaching and classroom use. Instead of SDL2, it renders to an ipycanvas canvas output, so it works in environments where you do not have a desktop window (e.g. JupyterLab, hosted JupyterHub).
The goal is API familiarity, not perfect drop-in compatibility. Many common drawing and event patterns work, but the browser and the widget stack impose limits.
Install
For local notebooks (CPython kernels), install from this repository:
pip install git+https://github.com/Kamuyin/ipygame.git
Quick start
import ipygame as pygame
screen = pygame.display.set_mode((420, 260))
screen.fill("midnightblue")
pygame.draw.rect(screen, "gold", (30, 30, 140, 80))
pygame.draw.circle(screen, "tomato", (280, 130), 50)
pygame.display.flip()
Examples
The examples/ folder contains notebooks for basic drawing, input handling, and small game demos.
Documentation
Docs and API reference: https://kamuyin.github.io/ipygame
Limitations and known issues
Some pygame features are not applicable in the browser or are not implemented yet. For a high-level view of what is currently covered, check the API coverage page in the docs.
Performance can be noticeably lower than desktop pygame. Rendering happens through the browser canvas and a widget message channel, so high-FPS loops and pixel-heavy effects pay extra overhead, and there is no native SDL2 window/GPU pipeline like on the desktop.
If you run the examples in JupyterLite (Pyodide), you may see rendering work while real-time keyboard/mouse input does not. This is a limitation of the Pyodide kernel + widget message processing for long-running loops, and it is not something ipygame can reliably fix from Python alone.
Audio is work in progress.
Acknowledgements
ipygame is based on the work by the pygame and pygame-ce projects and aims to provide a familiar API for educational notebooks. This project is not affiliated with, endorsed by, or a replacement for pygame/pygame-ce.
License
Licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1-only). See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 ipygame-0.1.0.tar.gz.
File metadata
- Download URL: ipygame-0.1.0.tar.gz
- Upload date:
- Size: 371.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65976215359b71f8fc39cd1e4da76595da9542494c69f40b3f9cc2d974877526
|
|
| MD5 |
e34d1499b18330efb1e82ef3cd7ecddf
|
|
| BLAKE2b-256 |
6dd09bf255f6a27234d5497ba6ef6866ac6b55442fc1dc7647cef1574711ae10
|
Provenance
The following attestation bundles were made for ipygame-0.1.0.tar.gz:
Publisher:
publish.yml on Kamuyin/ipygame
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipygame-0.1.0.tar.gz -
Subject digest:
65976215359b71f8fc39cd1e4da76595da9542494c69f40b3f9cc2d974877526 - Sigstore transparency entry: 970413926
- Sigstore integration time:
-
Permalink:
Kamuyin/ipygame@47a0532d4eda7991a33ecac3b0cb670f8f2fd74c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Kamuyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@47a0532d4eda7991a33ecac3b0cb670f8f2fd74c -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipygame-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipygame-0.1.0-py3-none-any.whl
- Upload date:
- Size: 68.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38f3aead34843f801fdcc94e7ece5138c5a3cced1f620add26c569dafd5972bd
|
|
| MD5 |
56dae623412d6a674aa8355fac886979
|
|
| BLAKE2b-256 |
0f30b966c82e9c01ed986cdf60061f2cc51af3696df658f1c22299975e06b90f
|
Provenance
The following attestation bundles were made for ipygame-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Kamuyin/ipygame
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipygame-0.1.0-py3-none-any.whl -
Subject digest:
38f3aead34843f801fdcc94e7ece5138c5a3cced1f620add26c569dafd5972bd - Sigstore transparency entry: 970413929
- Sigstore integration time:
-
Permalink:
Kamuyin/ipygame@47a0532d4eda7991a33ecac3b0cb670f8f2fd74c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Kamuyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@47a0532d4eda7991a33ecac3b0cb670f8f2fd74c -
Trigger Event:
push
-
Statement type: