The py5 Live Coding feature can be briefly described as a tool that runs your module mode1 sketch and keeps an eye on changes at the source file, updating the running sketch with any2 changes you save from your editor/IDE.
- It is not available for imported mode. In module mode you have to use
import py, the.py5prefix on py5 functions andpy5.run_sketch()in the end. Learn all about the py5 modes at The Five py5 Modes — py5 documentation - Well, almost any changes, there are a few limitations, nothing serious, you can read the details at Live Coding — py5 documentation, there are some extra goodies and settings too
This feature makes it really fast and a pleasure to modify and try small tweaks on a running py5 sketch.
If your environment is properly set up, like, you might need to activate the virtualenv where py5 was installed, then you should be able to invoke it from the command line using py5-live-coding sketch-source.py or maybe python -m py5_tools live-coding sketch-source.py, where sketch-source.py will be your sketch’s source file.
For people using py5 with the Thonny IDE, it usually works to enter !python -m py5_tools live-coding sketch-source.py (note the !) in the interactive shell at the bottom of the window, but Thonny must be “looking at the right directory”, that is, your file is at the last place it saved a file to, or at the last directory where Thonny ran some code.
In order to make all this easier for people using Thonny and py5 (and often unfamiliar with the command line interface, like many of my students and people who go to my activities at the community center where I work) I made an experimental version of the thonny-py5mode plug-in (the one that makes it easy to run imported mode sketches on Thonny) adding a new “Live Coding mode” option, code at: GitHub - villares/thonny-py5mode at live-coding-mode · GitHub
UPDATED: You should be able to test the experimental version of the plug-in downloading this file then using the Thonny panel at Tools > Manage plug-ins… and selecting the install form local file option. This is the first time I try packaging a plug-ins, let’s see how it goes!
And if you are on Windows, I have made an updated version of my portable Thonny bundle with py5 and the thonny-py5mode plug-in preinstalled for Windows: GitHub - lugaralgum/thonny-portable-with-py5 · GitHub and I’d appreciate feedback about this.