How to receive tab control event in Python mode

I have some controlP5 code in Java that I want to port to Python. It uses tabs and captures the control event when the tab is changed. However, in Python I don’t see these events.
What do I have to do to capture these control events in Python mode?


Also based on wonderful examples by @GoToLoop: :smile:

Based on code by GoToLoop


bg = 200
tx = 100

def setup():
    size(400, 300)

    global slider_a, slider_b
    slider_a = (ControlP5(this)
                .setSize(width / 2, 20)
                .setPosition(width / 4, height / 2)
                .setRange(0, 255)
    slider_b = (ControlP5(this)
                .setSize(width / 2, 20)
                .setPosition(width / 4, 40 + height / 2)
                .setRange(0, 255)

def draw():
    text("HELLO SLIDERS", 120, 120)

def sliderListener(evt):
    global bg, tx
    if evt.isFrom(slider_a):
        bg = int(evt.getValue())
    if evt.isFrom(slider_b):
        tx = int(evt.getValue())



Thank you very much for your answers. Unfortunately my question was not precise enough: I am not asking for control events in Python in general but I am asking for the control event emitted by the tab class when changing from one tab to the other. There is the method “activateEvent” to which I give the parameter “True” which should make the tab send events when you switch from one tab to the other.
While I see button or slider events I don’t see this tab event.
I also tried the lambda way, which also does not see the event.
The third possibility: adding a callback with cp5.addCallback again works on buttons but I don’t see the tab event.

1 Like