Skip to main content

coderius-play

The goal of coderius-play is to help starting programmers to become more capable in programming Python.

Installation

pip install coderius-play

coderius-play runs on Python 3.11 to 3.15 and is tested on Windows and Linux.

Raspberry Pi

On a Raspberry Pi with 64-bit Raspberry Pi OS (Bookworm or Trixie), install it in a virtual environment with the Python that comes with the system:

python3 -m venv ~/play-env
~/play-env/bin/pip install coderius-play

To use it from Thonny, open Run → Configure interpreter…, choose Local Python 3, click the … button next to Python executable and pick python3 in the play-env/bin folder in your home folder.

In the browser

With pygbag a play game runs in the browser. Name the file main.py, put it in a folder of its own and list coderius-play and pygame-ce at the top, so pygbag loads them:

# /// script
# dependencies = ["coderius-play", "pygame-ce"]
# ///
import play

play.new_text(words="Hello from the browser!")

play.start_program()

Then run pygbag my_game_folder and open http://localhost:8000. In the browser play.start_program() returns straight away and the page keeps the game running. Videos are not available there.

The same works in Pyodide 0.29 or newer: give pygame a canvas before play is imported, install play with micropip and run the game:

const pyodide = await loadPyodide();
pyodide.canvas.setCanvas2D(document.getElementById("canvas"));
await pyodide.loadPackage("micropip");
await pyodide.pyimport("micropip").install("coderius-play");
await pyodide.runPythonAsync(gameCode);

Both ways need coderius-play 3.5.0 or newer, the first release that runs in the browser.

Usage

Please visit the documentation.

Playing video

play.new_video() shows an .mp4 on screen, with built-in controls that appear when the mouse is over it:

import play

video = play.new_video("clip.mp4", width=480, autoplay=True)

@video.when_video_ends
def finished():
    print("that's all folks")

play.start_program()

The video can also be driven from code with video.play(), video.pause(), video.seek(10), video.time, video.volume, video.speed and video.loop. Video decoding uses PyAV, which is installed along with coderius-play and brings its own FFmpeg, so nothing else is needed.

Testing

Install the runtime and development dependencies, then run the suite:

pip install -r requirements.txt -r requirements-dev.txt
pytest tests

CI gates on formatting and linting as well as the tests. To run exactly what it runs before you open a pull request:

black --check ./play ./tests
pylint $(git ls-files 'play/*.py' 'play/**/*.py')
pytest ./tests -n auto --runslow --durations=10

Tests marked slow (and everything under tests/stress/) are skipped unless you pass --runslow.

Contributing

We welcome contributions! If you'd like to contribute, please follow these steps:

  • Fork the repository.

  • Create a new branch (git checkout -b feature/your-feature-name).

  • Commit your changes (git commit -m 'feat: Add a new feature').

  • Push to the branch (git push origin feature/your-feature-name).

  • Open a Pull Request.

Good luck and happy coding!

License

This project is licensed under the MIT License

Acknowledgements

Metadata

Release files for coderius-play 3.5.0

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

Source distribution (sdist)

Source distribution for coderius-play 3.5.0
File Size Uploaded Provenance Actions
coderius_play-3.5.0.tar.gz 93.0 kB Without provenance Details for coderius_play-3.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for coderius-play 3.5.0
File Interpreter ABI Platform Actions
coderius_play-3.5.0-py3-none-any.whl Python 3 none any Details for coderius_play-3.5.0-py3-none-any.whl

Total release size: 206.1 kB

Release files / coderius_play-3.5.0.tar.gz

Download URL coderius_play-3.5.0.tar.gz
Size 93.0 kB
Tags Source
SHA-256 checksum
How to use checksums
143232532e959cab1d820b23544d57d1212802e6f1322486c5c9eeadd9e04de2
BLAKE2b-256 checksum
How to use checksums
b9e6a670f96dc8e10c4706c0d47420794bfbed1f31eb864fb677338d83cbf024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / coderius_play-3.5.0-py3-none-any.whl

Download URL coderius_play-3.5.0-py3-none-any.whl
Size 113.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40542dc2a73ffb467dd36d6fa17259151047d363420f3699828e45424875afe9
BLAKE2b-256 checksum
How to use checksums
d744aaa98a7f4c311268e5abae7f0f7abd2c855f278085d44dbd0da1f596c68c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for coderius-play 3.5.0

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.

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