[IronPython] Accessing the Engine's module
Hi, is there any way to access the PythonEngine's module and frame (they are declared private) ? Thanks in advance Nandi ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Issues with methods as event handlers?
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
[IronPython] Creating Python file from .NET stream?
Is it possible to create Python file from .NET stream? IronPython/Runtime/PythonFile.cs seems to have code to do this, but I couldn't find a way to call this from Python side. Seo Sanghyeon ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] struct module and sys.byteorder
struct module is currently missing. In the mean time there's pure Python one at: http://codespeak.net/svn/pypy/dist/pypy/lib/struct.py But importing it raises AttributeError because sys.byteorder is missing in IronPython. Here's a workaround to put in site.py: import System import sys if System.Net.IPAddress.NetworkToHostOrder(1) == 1: sys.byteorder = 'big' else: sys.byteorder = 'little' Hope this help, Seo Sanghyeon ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[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/ import sys sys.LoadAssemblyByName("System.Windows.Forms") from System.Windows.Forms import * class ClickListener: def trigger(self, source, args): print "clickListener called: ", self.trigger clickListener = ClickListener() print "Checking method equality: ", clickListener.trigger == clickListener.trigger triggerButton = Button(Text = "Trigger") triggerButton.Dock = DockStyle.Top triggerButton.Click += clickListener.trigger removeButton = Button(Text = "Remove") removeButton.Dock = DockStyle.Bottom def remove(source, args): print "Removing ", clickListener.trigger triggerButton.Click -= clickListener.trigger removeButton.Click += remove form = Form() form.Controls.Add(triggerButton) form.Controls.Add(removeButton) Application.Run(form) import sys sys.LoadAssemblyByName("System.Windows.Forms") from System.Windows.Forms import * def click(source, args): print "clickListener called: ", click print "Checking method equality: ", click == click triggerButton = Button(Text = "Trigger") triggerButton.Dock = DockStyle.Top triggerButton.Click += click removeButton = Button(Text = "Remove") removeButton.Dock = DockStyle.Bottom def remove(source, args): print "Removing ", click triggerButton.Click -= click removeButton.Click += remove form = Form() form.Controls.Add(triggerButton) form.Controls.Add(removeButton) Application.Run(form) ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Issues with methods as event handlers?
Hi all, I attach an example of a workaround for the problem. Cheers, Giles -- Giles Thomas Resolver Systems [EMAIL PROTECTED] 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 import sys sys.LoadAssemblyByName("System.Windows.Forms") from System.Windows.Forms import * class ClickListener: def trigger(self, source, args): print "clickListener called: ", self.trigger clickListener = ClickListener() def pseudoMethod(source, args): clickListener.trigger(source, args) print "Checking method equality: ", pseudoMethod == pseudoMethod triggerButton = Button(Text = "Trigger") triggerButton.Dock = DockStyle.Top triggerButton.Click += pseudoMethod removeButton = Button(Text = "Remove") removeButton.Dock = DockStyle.Bottom def remove(source, args): print "Removing ", pseudoMethod triggerButton.Click -= pseudoMethod removeButton.Click += remove form = Form() form.Controls.Add(triggerButton) form.Controls.Add(removeButton) Application.Run(form) ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com