# ControlP5 in py5

**URL:** <https://discourse.processing.org/t/controlp5-in-py5/45799>\
**Category:** py5\
**Created:** [February 19, 2025, 5:24pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799 "2025-02-19T17:24:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [February 19, 2025, 5:24pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/1 "2025-02-19T17:24:24Z")

</div>

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_.

```python
# 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:**

 ![cw](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/f/af14e43982ffb030bda820055e99cf67dd48a2fe.png)

**Requisite jar file for ‘jars’ folder:**

 ![jar](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/2/627705cf3d9f9edfdb8ac1e4bbb0765bbd9ac1bf.png)  
 ![library_fldr](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/0/104f8ba5213cf037cfc0e2fec5cbb199bfd117c5.png)

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 25, 2026, 2:23pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/2 "2026-02-25T14:23:21Z")

</div>

This is so cool, @svan! I love this, thank you for sharing it.

With the `py5_tools.processing.download_library()` feature it becomes even easier to use it, you don’t have to manually copy the `jar` file!

Check out my attempt at simplifying a bit the sketch:

![peek_1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/7/e7a440cd650ce99d97966cc3c8b1b616c39915f2.gif)

```python
# Uses Imported mode for py5, learn more at <py5coding.org>

# To install the ControlPy5 .jar, you only need the following two lines once
from py5_tools.processing import download_library
print(download_library('ControlP5')) # printed to see details of how it went

from controlP5 import ControlP5 # on module mode, this must come after import py5

def setup():
    global slider, cw
    size(450, 450)

    window_title("DotView Demo") 
    this = get_current_sketch()
    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():
    background(209)
    fill(cw.getRGB())
    circle(200, 220, slider.getValue())

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 25, 2026, 7:09pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/3 "2026-02-25T19:09:17Z")

</div>

> [@villares](#):
>
> With the `py5_tools.processing.download_library()` feature it becomes even easier to use it, you don’t have to manually copy the `jar` file!

Cool beans!

I had to make these changes for the @villares version to work with Windows 10:

```processing
# Uses Imported mode for py5

# Extras
print(py5_tools.processing.library_storage_dir())
print(py5_tools.processing.installed_libraries())

from py5_tools.processing import download_library
println(download_library('ControlP5'))

# This did not work in Windows 10
# from controlP5 import ControlP5

# This worked in Windows 10
from py5 import JClass
ControlP5 = JClass("controlP5.ControlP5")

```

That last part was suggested by Chat GPT.  
I did not find a reference to that in the py5 site.

_I have not visited this in a while so it may be related to my setup._

This @svan version in the original post worked as is with this addition:

> [@svan](#):
>
> In addition, the **controlP5.jar** must be in a folder entitled ‘jars’ in the py5 sketch folder.

`:)`

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 25, 2026, 9:20pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/4 "2026-02-25T21:20:06Z")

</div>

Cheers @glv !

It is great that you could make it work… but I don’t think you should need to import JClass, py5 should take care of it for you. This might be an issue that we might want to show to @hx2A…

Can you give us more information about your setup?  
Windows 10 has been giving us trouble with the Thonny plug-in sometimes.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 25, 2026, 9:29pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/5 "2026-02-25T21:29:00Z")

</div>

Hello @villares,

I believe I simply followed the instructions on the site a while back.

Working with W10:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/8/b81a59470d2aef3ce5ebb6384aa9abf37d77a76a.png)

This did not work:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/a/aaa23d00083d4aae08d5c5bdf325d604d659ffd3.png)

I then updated everything (not from scratch) and no change.

Reports version numbers:

```auto
import sys
import py5
from importlib.metadata import version, PackageNotFoundError

python_version = sys.version.split()[0]
py5_version = getattr(py5, " __version__", "unknown")

try:
    thonny_py5mode_version = version("thonny-py5mode")
except PackageNotFoundError:
    thonny_py5mode_version = "not installed"

print("Python:", python_version)
print("py5:", py5_version)
print("thonny-py5mode:", thonny_py5mode_version)

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/a/4a3b5301224f9d5d077c5b92bf17f2aa07104efb.png)

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [February 25, 2026, 10:16pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/6 "2026-02-25T22:16:57Z")

</div>

On a Windows 11 system I am also unable to run your revision. My findings are similar to @glv. It can be made to work by one of two methods:

1. import JClass

2. Alternatively copy/paste the controlP5.jar as described in the original post.

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 25, 2026, 11:21pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/7 "2026-02-25T23:21:23Z")

</div>

I’ll see if I can try this tomorrow at my Community Center job. Then I can help filing an issue. Can you please, @glv and @svan, try the same thing on _module mode_?

That would be using `import py5` then the `py5.` prefix everywhere and `py5.run_sketch()` in the end (turning off the “imported mode for py5” option on Thonny).

If that works it would be a hit that something on _imported mode_ is going wrong.

---

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [February 25, 2026, 11:29pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/8 "2026-02-25T23:29:22Z")

</div>

> [@glv](#):
>
> ```auto
> # This did not work in Windows 10
> # from controlP5 import ControlP5
> 
> # This worked in Windows 10
> from py5 import JClass
> ControlP5 = JClass("controlP5.ControlP5")
> 
> ```

It is very interesting to me that the first bit of code does not work on Windows 10 and the second piece does. The first part is leveraging a jpype feature that adds import hooks to let you import java classes. Perhaps jpype can’t do that on Windows 10 for some reason?

Recall we also have a problem with the Thonny plugin not working correctly on Windows 10. Parts of py5 are written with the expectation that the import hooks work. Perhaps these two things are related?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 25, 2026, 11:37pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/9 "2026-02-25T23:37:03Z")

</div>

> [@villares](#):
>
> try the same thing on _module mode_?

Results in comments

```processing
# Works:
from controlP5 import ControlP5
print("ControlP5: import")

# Does NOT work:
# ControlP5 = JClass("controlP5.ControlP5")
# print("ControlP5: JClass")

slider = None
cw = None

def settings():
    py5.size(450, 450)

def setup():
    global slider, cw

    py5.window_title("DotView Demo")
    this = py5.get_current_sketch()

    cp5 = ControlP5(this)
    slider = cp5.addSlider("slider", 0, 255, 50, 30, 10, 200, 20)
    cw = cp5.addColorWheel("c", 300, 10, 100)
    cw.setRGB(py5.color(128, 0, 255))

def draw():
    py5.background(209)
    py5.fill(cw.getRGB())
    py5.circle(200, 220, slider.getValue())

py5.run_sketch()

```

`:)`

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 25, 2026, 11:44pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/10 "2026-02-25T23:44:57Z")

</div>

Thank you for helping with this! So does the sketch work on _module mode_?  
(I see no error messages)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 25, 2026, 11:47pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/11 "2026-02-25T23:47:23Z")

</div>

> [@villares](#):
>
> So does the sketch work on _module mode_?

I unchecked “Imported mode for py5” and ran the code:

> [@glv](#):
>
> ```auto
> # Works:
> from controlP5 import ControlP5
> print("ControlP5: import")
> 
> ```

Is that module mode?

I am not that familiar with all the modes.

The answer is here I am sure:

> **[The Five py5 Modes — py5 documentation](https://py5coding.org/content/py5_modes.html)**

Still trying to find time to get back into learning Python.

`:)`

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 25, 2026, 11:51pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/12 "2026-02-25T23:51:28Z")

</div>

Yes, that should be _module mode_! Does the sketch window open?  
With the sliders, etc. ?

I usually use _imported mode_ and sometimes _static mode_ in class, and _module mode_ by myself and with advanced students… [The Five py5 Modes — py5 documentation](https://py5coding.org/content/py5_modes.html)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 25, 2026, 11:53pm UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/13 "2026-02-25T23:53:06Z")

</div>

> [@villares](#):
>
> Yes, that should be _module mode_! Does the sketch window open?  
> With the sliders, etc. ?

It opens confidently with unbridled enthusiasm!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/a/bafff37b18ca3751266ccc377838a9efa95b70aa.png)

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [February 26, 2026, 12:59am UTC](https://discourse.processing.org/t/controlp5-in-py5/45799/14 "2026-02-26T00:59:11Z")

</div>

I can confirm that it does work on a Windows 11 system in `module mode`, but not in imported mode.
