You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
py5 is a new version of [**Processing**][processing] for Python 3.8+. It makes the Java [**Processing**][processing] jars available to the CPython interpreter using [**JPype**][jpype]. It can do just about everything [**Processing**][processing] can do, except with Python instead of Java code.
10
+
11
+
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 such as [numpy](https://www.numpy.org/) or [Pillow](https://python-pillow.org/).
12
+
13
+
## Simple Example
14
+
15
+
Here is a simple example of a working py5 Sketch, written in module mode:
16
+
17
+
```python3
18
+
import py5
19
+
20
+
21
+
defsetup():
22
+
py5.size(200, 200)
23
+
py5.rect_mode(py5.CENTER)
24
+
25
+
26
+
defdraw():
27
+
py5.square(py5.mouse_x, py5.mouse_y, 10)
28
+
29
+
30
+
py5.run_sketch()
31
+
```
32
+
33
+
## Installation
34
+
35
+
If you have Java 17 installed on your computer, you can install py5 using pip:
36
+
37
+
```bash
38
+
pip install py5
39
+
```
40
+
41
+
[Detailed installation instructions](https://py5.ixora.io/content/install.html) are available on the documentation website. There are some [Special Notes for Mac Users](https://py5.ixora.io/content/osx_users.html) that you should read if you use OSX.
42
+
43
+
## Getting Started
44
+
45
+
There are currently four basic ways to use py5. They are:
46
+
47
+
***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.
48
+
***class mode**: create a Python class inherited from `py5.Sketch`. This mode supports multiple Sketches running at the same time.
49
+
***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.
50
+
***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.
51
+
52
+
The documentation website, [https://py5.ixora.io/](https://py5.ixora.io/), is a work in progress. The reference documentation is solid but the how-to's and tutorials are a work in progress.
53
+
54
+
[py5generator][py5_generator_repo] is a meta-programming project that creates the py5 library. To view the actual installed py5 library code, look at the [py5 repository][py5_repo]. All py5 library development is done through py5generator.
55
+
56
+
## Get In Touch
57
+
58
+
Have a comment or question? We'd love to hear from you! The best ways to reach out are:
59
+
60
+
* github [discussions](https://github.com/hx2A/py5generator/discussions) and [issues](https://github.com/hx2A/py5generator/issues)
Copy file name to clipboardExpand all lines: py5/sketch.py
+40-9Lines changed: 40 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -61,9 +61,9 @@
61
61
# be aware that __IPYTHON__ and get_ipython() are inserted into the user
62
62
# namespace late in the kernel startup process
63
63
__IPYTHON__ # type: ignore
64
-
if sys.platform == 'darwin' and get_ipython(
65
-
).active_eventloop != 'osx': # type: ignore
66
-
print("Importing py5 on OSX but the necessary Jupyter OSX event loop not been activated. I'll activate it for you, but next time, execute `%gui osx` before importing this library.")
print("Importing py5 on OSX but the necessary Jupyter OSX event loop has not been activated. I'll activate it for you, but next time, execute `%gui osx` before importing this library.")
0 commit comments