# How to active ControlEvent in ControlP5 - python Mode?

**URL:** <https://discourse.processing.org/t/how-to-active-controlevent-in-controlp5-python-mode/1113>\
**Category:** Processing.py\
**Created:** [June 20, 2018, 5:59am UTC](https://discourse.processing.org/t/how-to-active-controlevent-in-controlp5-python-mode/1113 "2018-06-20T05:59:27Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 20, 2018, 9:09am UTC](https://discourse.processing.org/t/how-to-active-controlevent-in-controlp5-python-mode/1113/6 "2018-06-20T09:09:32Z")

</div>

```auto
"""
 ControlP5::addListener() (v1.1)
 GoToLoop (2018-Jun-20)

 https://Discourse.Processing.org/t/
 how-to-active-controlevent-in-controlp5-python-mode/1113/6
"""

add_library('controlP5')

bg = 0200

def setup():
    size(400, 300)

    global slider
    slider = ControlP5(this).\
             addSlider('slider').\
             setSize(width>>1, 20).\
             setPosition(width>>2, height>>1).\
             setRange(0, 0xff).\
             setValue(bg).\
             addListener(sliderListener)

def draw(): background(bg)

def sliderListener(evt):
    global bg
    bg = int(evt.getValue())

```

---

_[View the full topic](https://discourse.processing.org/t/how-to-active-controlevent-in-controlp5-python-mode/1113)._
