Another option that should work is: class ClickListener: def trigger(self, source, args): print "..."
a = ClickListener() b = a.trigger triggerButton.Click += b triggerButton.Click -= b What you're experiencing is the fact that trigger is actually just a callable object. When you do a.trigger you get a new bound method object that is different from the bound method object you get back when you do the -=. We should see if there's a way for us to fix this to match expecations so I'll go ahead and make sure we get the bug filed. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Giles Thomas Sent: Wednesday, February 01, 2006 11:10 AM To: Discussion of IronPython Subject: [IronPython] Issues with methods as event handlers? Hi all, When we use bound methods as Windows Forms event handlers, we can't detach them. Functions work OK. To see the problem, run up the attached button_method.py using IronPythonConsole; if you click on the "Trigger" button, you'll see a log message in the console saying that the trigger method has been called. Click on the "Remove" button to remove the event handler, and then click on the "Trigger" button again - you'll still get the log message. So the event handler was not detached correctly. By contrast, if you do the same thing using button_function.py, you will see that once you have clicked on "Remove", the "Trigger" button's handler will be correctly detached, so further clicks on that button will not generate log messages. We've tested against beta 2, beta 1, and 0.9.5 (which latter doesn't display the button labels but otherwise behaves as described above). Hope this helps someone :-) Cheers, Giles -- Giles Thomas Resolver Systems [EMAIL PROTECTED] We're hiring! http://www.resolversystems.com/jobs/ _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com