Skip to content

Receive decorator events inside of class #8

Description

@frederikbrammer

Hey there,

I would like to organize everything related to the Ableton Push interaction inside of a class named PushService. However, when the decorated function is called, I need to have access to the object's properties. How can I access self property inside of that function?

Here's my class definition:

classPushService():
def__init__(self, eventQueueService: EventQueueService):
self.eventQueueService=eventQueueServiceprint("Initializing push service...")
self.push=push2_python.Push2(run_simulator=True)
# Start by setting all pad colors to whiteself.push.pads.set_all_pads_to_color('white')
@push2_python.on_pad_pressed()defon_pad_pressed(push, pad_n, pad_ij, velocity):
ifpad_ij== (7,7):
self.eventQueueService.registerBeat() # <= Here I need access to the self property to call the registerBeat function# Set pressed pad color to greenprint('Pad', pad_ij, 'pressed with velocity', velocity)
push.pads.set_pad_color(pad_ij, 'green')

Thanks a lot in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions