How to access 'system variable' directly in Python code?

Dear All,

I’m using the processing-py 0.3.7 library directly in visual studio code. The because I want to combine the results with other code/libraries. The thing i’m stuck with is how do I access a ‘system variable’ such as frameCount?

For example when defined the app as:

app = App(800,800)

you can access it by:


But how do you access frameCount? For example in the following case:

def draw(app):

    if (frameCount()  % 10 == 0):

Thanks in advance for any help.

1 Like

The command line feature that allows one to use Processing Python mode outside the Processing IDE is not currently maintained, unfortunately. I always had a hard time making it work. There was some discussion on using it with Atom: How to run Processing Python Mode in Atom? - #3 by BeastCoder and maybe VS Code but I couldn’t find them right now.

I’m unfamiliar with the kind of instantiation you are doing. For simple sketches
one should be able to just use the global name frameCount, I believe. :confused:

Another idea, if you want to integrate with modern Python libraries, would be to use a completely external Python 3 environment using py5 (Python 3 + Java with JPype) or p5py (Python 3, no Java) instead. :slight_smile:

1 Like

Python Mode in the PDE creates a global variable named this which holds the PApplet reference for the whole sketch.


@villares’ py5 link is broken. @sweetart, you can use this link:

If by “other code/libraries” you mean other Python libraries and/or Processing libraries, then you’ll want to opt for py5 over pyp5.

1 Like

thanks! I fixed the link now I think!

1 Like

Dear All,

Thank you for your answers. I downloaded the py5 libary and I’m going to try to create the code with this.

Kind regards.