messenger question

Hi! I am wondering if there is a way to allow the messenger (in detail the accept() ) to call something like

self.accept('xpressed', self.x=self.x+1)

I am somewhat confused why I need to call

self.accept('xpressed'. self.xPressed)
def xPressed(self):

I HOPE that there will be an easier way… otherwise the messenger is somewhat useless if you want to use it for custom messages - you can call the function then directly instead of first creating a message, handling the message then and THEN getting the needed function done…

Or is that only me?

Regards, Bigfoot29

Sure, you need to use the “anonymous function” syntax of Python. That looks like this:

self.accept('xpressed', lambda s = self: s.x=s.x+1)

You can look up more about this syntax at, but the above example creates an on-the-fly function that binds “s” to “self”.