Skip to main content

Processing for CPython

Project description

py5

py5 montly downloads

py5 weekly downloads

mybinder

py5 is a new version of Processing for Python 3.8+. It makes the Java Processing jars available to the CPython interpreter using JPype. It can do just about all of the 2D and 3D drawing Processing can do, except with Python instead of Java code.

The goal of py5 is to create a new version of Processing that is integrated into the Python ecosystem. Built into the library are thoughtful choices about how to best get py5 to work with other popular Python libraries and tools such as Jupyter, numpy, and Pillow.

Simple Example

Here is a simple example of a working py5 Sketch, written in module mode:

import py5


def setup():
    py5.size(400, 400)
    py5.rect_mode(py5.CENTER)


def draw():
    py5.square(py5.mouse_x, py5.mouse_y, 10)


def mouse_clicked():
    py5.fill(py5.random_int(255), py5.random_int(255), py5.random_int(255))


py5.run_sketch()

Installation

If you have Java 17 installed on your computer, you can install py5 using pip:

pip install py5

Detailed installation instructions are available on the documentation website. There are some Special Notes for Mac Users that you should read if you use OSX.

Getting Started

There are currently four basic ways to use py5. They are:

  • module mode: create a sketch with setup() and draw() functions that call methods provided by the py5 library. The above example is created in module mode.
  • class mode: create a Python class inherited from py5.Sketch. This mode supports multiple Sketches running at the same time.
  • imported mode: simplified code that omits the py5. prefix. This mode is supported by the py5 Jupyter notebook kernel and the run_sketch command line utility.
  • static mode: functionless code to create static images. This mode is supported by the py5bot Jupyter notebook kernel, the %%py5bot IPython magic, and the run_sketch command line utility.

The documentation website, https://py5.ixora.io/, is a work in progress. The reference documentation is solid but the how-to's and tutorials are incomplete.

py5generator is a meta-programming project that creates the py5 library. To view the actual installed py5 library code, look at the py5 repository. All py5 library development is done through py5generator.

Get In Touch

Have a comment or question? We'd love to hear from you! The best ways to reach out are:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py5-0.8.2a1.tar.gz (11.4 MB view hashes)

Uploaded source

Built Distribution

py5-0.8.2a1-py3-none-any.whl (11.5 MB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page