[TUTORIAL]Running Python Mode in VScode

This is the method that I used to get processing.py sketches to run in VScode.

You will need:

  • Java to be installed and added to path
  • The file processing-py.jar
  • The Code runner extension

To get the first two items refer to the tutorial on how to run processing.py sketches on the command line here.

  1. Open up a new workspace and create a python file with the processing code you want to run.
    Example code:
# mouse_follow.py
def setup():
    size(400,400)

def draw():
    background(255)
    fill(0)
    ellipse(mouseX, mouseY, 50, 50)
  1. Add the processing-py.jar file in the same workspace.
  2. In the settings.json file under WORKSPACE SETTINGS tab, add the line:
 "code-runner.customCommand": "java -jar processing-py.jar mouse_follow.py"

So it should look something like this:

{
    "code-runner.customCommand": "java -jar processing-py.jar mouse_follow.py"
}
  1. Run the command Run Custom Command (Ctrl + Alt + K)
  2. Bask in the glory of your work.

NB: The file processing-py.jar can be located anywhere just add its path to the custom command.

Let me know if you get stuck on any part of this, I will try to help you.
No, Thankyou!

6 Likes

Thank you so much for creating this!

1 Like

very nice! I’m doing a presentation about creative coding with Python and this will be very useful, thanks for sharing!

2 Likes

I was wondering if anyone starting Processing from VS Code or from the command line know how to control the location of the Processing application? I’m running in two screens, and I’d like to set where the sketch will show up on the screen after launch.

I have not tested it (because I don’t have a second monitor right now), but see if fullscreen() would help:

https://py.processing.org/reference/fullScreen.html

fullScreen()
fullScreen(display)
fullScreen(renderer)
fullScreen(renderer, display)

Known issues: https://github.com/jdf/processing.py/issues/346

1 Like