The following source code demonstrates using cp5 controls in py5. This demo may be run in a Thonny editor using ‘Imported mode for py5’. In addition, the controlP5.jar must be in a folder entitled ‘jars’ in the py5 sketch folder. The controlP5.jar file may be copy/pasted from your Processing libraries folder; on MacOS it is located at the following path: Documents/Processing/libraries/controlP5/library/controlP5.jar.
# Uses Imported mode for py5
from controlP5 import ControlP5
this = get_current_sketch()
print(this)
def settings():
size(450,400)
def setup():
global slider
global cw
window_title("DotView Demo")
cp5 = ControlP5(this)
slider = cp5.addSlider("slider", 0, 255, 50, 30, 10, 200, 20)
cw = cp5.addColorWheel("c", 300,10,100)
cw.setRGB(color(128,0,255))
def draw():
global slider
global cw
background(209)
fill(cw.getRGB())
circle(200,220,slider.getValue())
Output:
Requisite jar file for ‘jars’ folder: