I have class Window. This class has method onClick which gets argument the id of control clicked on that window (i can not change the way it's work):
class Window(SoneBaseWindowClass):
def onClick(self,controlID):
print controlID
I want to make decorator which will add my method to callback stack. And than method onClick will call certain method when certain control get clicked. So:
class Window(SoneBaseWindowClass):
def __init__(self):
callback_stack = {}
def onClick(self,controlId):
callback = self.callback_stack.get(controlID)
if callback is not None:
callback()
# suppose to add decorated method to a callback_stack
def onclick_decorator(method):
pass
So I need to make decorator which will add some method to callback_stack
. Example using.
class MyWindow(Window):
@onclick_decorator(12345)
def someMethod(self):
print "Gets called when control with id 12345 clicked"
Actually the question is how can i get acces to class from onclick_decorator
Self is not passed to that method. So i can assume that it could get acces to class, but could not figure out how.