[IronPython] Issues with methods as event handlers?

Giles Thomas giles.thomas at resolversystems.com
Wed Feb 1 20:19:51 CET 2006


Hi all,

I attach an example of a workaround for the problem.


Cheers,

Giles
-- 
Giles Thomas
Resolver Systems
giles.thomas at resolversystems.com
We're hiring! http://www.resolversystems.com/jobs/


Giles Thomas wrote:
> 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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: button_pseudo_method.py
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060201/3cd36f82/attachment.ksh>


More information about the Ironpython-users mailing list