Sliders for the Python mode of Processing
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Sliders for the Python mode of Processing

If you use the Python mode for Processing, now you can add sliders to your sketch to change variable values dynamically. Simply put into the same folder as your sketch and import the Slider class at the top:

from slider import Slider

Outside the setup function, create the slider object by giving it a range (here it's 0 to 20) and a default value for when it first runs (in this case, 6):

slider1 = Slider(0,20,6)

Inside the setup function, give the slider a position:


In the draw function, assign the value of the slider to a variable:

num = slider1.value()

You have the option of labeling the slider, too:

slider1.label = "number"

I've included a couple of example files to show how it works in action. Have fun and let me know how you like it!