From eyakubovich at Getcollc.com Tue Jan 17 23:09:22 2006 From: eyakubovich at Getcollc.com (Eugene Yakubovich) Date: Tue, 17 Jan 2006 16:09:22 -0600 Subject: [Python.NET] Custom delegates and wrapping class instance in .net object Message-ID: Hi, I'm using Python .Net in conjuction with .Net WinForms to do some GUI development. What I have is one class that derives from Control and has all the GUI code and one class that handles all the network I/O (using standard Python sockets). The network I/O code runs in a separate thread and when it receives some data it needs to pass it to the GUI thread to display it. What I need is a custom delegate. If it was a C# program, it would be really easy to create: public delegate void DataArrived(object data); With Python.Net I don't see how I can do that. What I ended up doing is writing a simple assembly in C# that just contains the following lines: public delegate void NoArgDelegate(); public delegate void ObjectArgDelegate(object arg); public delegate void ArrayArgDelegate(object[] arg); My hope is to keep this utility assembly around for those times when I need a custom delegate. The delegates are somewhat general and with the last one, it is possible to pass as many arguments as needed. I would like to know, however, if anyone else encountered this problem and how they solved it. Is there a way to solve it with pure Python .Net (without C#)? If not, maybe a custom delegate(s) should be included into Python .Net? My second problem is that I can't pass Python class instances as arguments to my delegates. For example: def callback(arg): pass d = ObjectArgDelegate(callback) class PythonClass(object): pass d(PythonClass()) Results in: TypeError: no method matches given arguments Is there a way to convert a python class instance to a .Net object and then convert it back to python class instance? Eugene eyakubovich at getcollc.com From brian at zope.com Thu Jan 19 20:30:41 2006 From: brian at zope.com (Brian Lloyd) Date: Thu, 19 Jan 2006 14:30:41 -0500 Subject: [Python.NET] Custom delegates and wrapping class instance in .netobject In-Reply-To: Message-ID: > What I need is a custom delegate. If it was a C# program, it > would be really easy to create: > public delegate void DataArrived(object data); > > With Python.Net I don't see how I can do that. What I ended up doing is > writing a simple assembly in C# that just contains the following lines: > > public delegate void NoArgDelegate(); > public delegate void ObjectArgDelegate(object arg); > public delegate void ArrayArgDelegate(object[] arg); > > My hope is to keep this utility assembly around for those times when I > need a custom delegate. The delegates are somewhat general and with the > last one, it is possible to pass as many arguments as needed. I would > like to know, however, if anyone else encountered this problem and how > they solved it. Is there a way to solve it with pure Python .Net > (without C#)? If not, maybe a custom delegate(s) should be included into > Python .Net? I don't think I understand what you're trying to do well enough to advise here - if you can post an example that would be helpful. > > My second problem is that I can't pass Python class instances as > arguments to my delegates. For example: > > def callback(arg): > pass > d = ObjectArgDelegate(callback) > > class PythonClass(object): > pass > > d(PythonClass()) > > Results in: > > TypeError: no method matches given arguments > > > Is there a way to convert a python class instance to a .Net object and > then convert it back to python class instance? In this case, you should just be able to have PythonClass inherit from System.Object - that will get it a default conversion that should work for what you want to do. Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From admin at diamondturning.kiev.ua Mon Jan 23 09:09:29 2006 From: admin at diamondturning.kiev.ua (Eugene) Date: Mon, 23 Jan 2006 11:09:29 +0300 Subject: [Python.NET] About PythonEngine.RunString Message-ID: <43D48F39.6090000@diamondturning.kiev.ua> Hello All! I'm new in C#. Now I try embed Python in my C# prog. I wrote public partial class Form1 : Form { PyObject m; string ans="none"; public Form1() { InitializeComponent(); PythonEngine.Initialize(); m =PythonEngine.RunString("2+3"); ans = m.ToString; <- How i can eval answer from RunString?! label1.Text = ans; } when i debug and see the m variable - watch say m=Null why?! what i'm doing wrong?! Thanks! } From f.geiger at vol.at Wed Jan 25 10:46:03 2006 From: f.geiger at vol.at (Franz GEIGER) Date: Wed, 25 Jan 2006 10:46:03 +0100 Subject: [Python.NET] Any plans for supporting CLR2.0? Message-ID: <200601251046.04107.f.geiger@vol.at> Dear all, I'd like to integrate CPython- and Boo-programs. As I am already on CLR2.0 I wonder when Python for .NET could be available for CLR2.0. As its install file suggests it is ready for CLR1.1 only, right? Kind regards Franz GEIGER From brian at zope.com Wed Jan 25 17:10:55 2006 From: brian at zope.com (Brian Lloyd) Date: Wed, 25 Jan 2006 11:10:55 -0500 Subject: [Python.NET] Any plans for supporting CLR2.0? In-Reply-To: <200601251046.04107.f.geiger@vol.at> Message-ID: > Dear all, > > I'd like to integrate CPython- and Boo-programs. As I am already > on CLR2.0 I > wonder when Python for .NET could be available for CLR2.0. As its install > file suggests it is ready for CLR1.1 only, right? > > Kind regards > Franz GEIGER The pre-built versions I post are currently built for 1.1, but you should be able to build it against 2.x with minimal pain (though it wont support 2.x-only features, of course). Michael Eddington posted a build against 2.0 back in October: http://mail.python.org/pipermail/pythondotnet/2005-October/000406.html I hope to get some time starting in Feb. to work on some bugs that have been reported and implement support for generics, etc. I've been slacking off a bit lately given that IronPython really seems to be taking off, but it seems like it would still be useful to have a native bridge with support for at least the bigger changes in CLR 2.x. Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From brian at zope.com Wed Jan 25 17:54:32 2006 From: brian at zope.com (Brian Lloyd) Date: Wed, 25 Jan 2006 11:54:32 -0500 Subject: [Python.NET] Any plans for supporting CLR2.0? In-Reply-To: <1138207651.43d7aba31e77e@webmail.raincode.com> Message-ID: The crash is probably related to the attached problem that Michael worked through... Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: Stanislas Pinte [mailto:stan at phidani.be] > Sent: Wednesday, January 25, 2006 11:48 AM > To: Brian Lloyd; pythondotnet at python.org; f.geiger at vol.at > Subject: Re: [Python.NET] Any plans for supporting CLR2.0? > > > Hello, just pointing the tools (csc, dasm and ildasm) to the .Net > 2.0 versions gives a good build, > with some warnings, but python.exe crashes immediately. > > [pythonnet-1.0-rc2-py2.4-clr1.1-src]> ./python.exe > 'import site' failed; use -v for traceback > Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > > Unhandled Exception: System.AccessViolationException: Attempted > to read or write > protected memory. This is often an indication that other memory > is corrupt. > at Python.Runtime.Runtime.Py_Main(Int32 argc, String[] argv) > at Python.Runtime.PythonConsole.Main(String[] args) > [pythonnet-1.0-rc2-py2.4-clr1.1-src]> > > Any idea why? > > Thanks a lot, > > Stan. > > > > -------------- next part -------------- An embedded message was scrubbed... From: "Michael Eddington" Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 Date: Thu, 15 Sep 2005 14:00:03 -0500 Size: 7084 Url: http://mail.python.org/pipermail/pythondotnet/attachments/20060125/1b2d26d7/attachment.mht From stan at phidani.be Wed Jan 25 17:47:31 2006 From: stan at phidani.be (Stanislas Pinte) Date: Wed, 25 Jan 2006 17:47:31 +0100 Subject: [Python.NET] Any plans for supporting CLR2.0? Message-ID: <1138207651.43d7aba31e77e@webmail.raincode.com> Hello, just pointing the tools (csc, dasm and ildasm) to the .Net 2.0 versions gives a good build, with some warnings, but python.exe crashes immediately. [pythonnet-1.0-rc2-py2.4-clr1.1-src]> ./python.exe 'import site' failed; use -v for traceback Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Python.Runtime.Runtime.Py_Main(Int32 argc, String[] argv) at Python.Runtime.PythonConsole.Main(String[] args) [pythonnet-1.0-rc2-py2.4-clr1.1-src]> Any idea why? Thanks a lot, Stan. From fgeiger at datec.at Wed Jan 25 10:03:40 2006 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 25 Jan 2006 10:03:40 +0100 Subject: [Python.NET] Any plans for supporting CLR2.0? Message-ID: <200601251003.40692.fgeiger@datec.at> Dear all, I'd like to integrate CPython- and Boo-programs. As I am already on CLR2.0 I wonder when Python for .NET could be available for CLR2.0. As it's install file suggests it is ready for CLR1.1 only, right? Kind regards Franz GEIGER From mark.mcmahon at eur.autodesk.com Wed Jan 25 17:16:12 2006 From: mark.mcmahon at eur.autodesk.com (Mark McMahon) Date: Wed, 25 Jan 2006 11:16:12 -0500 Subject: [Python.NET] Any plans for supporting CLR2.0? Message-ID: <4187BAA24A3D094F925AEE0BE39B7077019B5161@msgusaemb01.autodesk.com> Hi Brian, I must say that Python.NET feels like an approach I would use more than IronPython. I like being able to mix both C extensions and .NET extensions together. I haven't had a need for .NET functionality yet, but if I do it will have to be Python.NET because the rest of my code makes extensive use of ctypes. Thanks Mark -----Original Message----- From: pythondotnet-bounces+mark.mcmahon=autodesk.com at python.org [mailto:pythondotnet-bounces+mark.mcmahon=autodesk.com at python.org] On Behalf Of Brian Lloyd Sent: Wednesday, January 25, 2006 11:11 AM To: f.geiger at vol.at; pythondotnet at python.org Subject: Re: [Python.NET] Any plans for supporting CLR2.0? > Dear all, > > I'd like to integrate CPython- and Boo-programs. As I am already > on CLR2.0 I > wonder when Python for .NET could be available for CLR2.0. As its install > file suggests it is ready for CLR1.1 only, right? > > Kind regards > Franz GEIGER The pre-built versions I post are currently built for 1.1, but you should be able to build it against 2.x with minimal pain (though it wont support 2.x-only features, of course). Michael Eddington posted a build against 2.0 back in October: http://mail.python.org/pipermail/pythondotnet/2005-October/000406.html I hope to get some time starting in Feb. to work on some bugs that have been reported and implement support for generics, etc. I've been slacking off a bit lately given that IronPython really seems to be taking off, but it seems like it would still be useful to have a native bridge with support for at least the bigger changes in CLR 2.x. Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet From roman.yakovenko at gmail.com Thu Jan 26 05:01:40 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Thu, 26 Jan 2006 06:01:40 +0200 Subject: [Python.NET] Any plans for supporting CLR2.0? In-Reply-To: <4187BAA24A3D094F925AEE0BE39B7077019B5161@msgusaemb01.autodesk.com> References: <4187BAA24A3D094F925AEE0BE39B7077019B5161@msgusaemb01.autodesk.com> Message-ID: <7465b6170601252001w47e37150w73e21621b1634ba6@mail.gmail.com> On 1/25/06, Mark McMahon wrote: > Hi Brian, > > I must say that Python.NET feels like an approach I would use more than IronPython. I am second to this opinion. If I do not want\need to embed Python within CLR or .NET application I definitely do not want to install and use an other Python interpreter. CPython interpreter works fine. Just my opinion. > I like being able to mix both C extensions and .NET extensions together. > > I haven't had a need for .NET functionality yet, but if I do it will have to be Python.NET because the rest of my code makes extensive use of ctypes. > > Thanks > Mark > Thanks Roman Yakovenko From hernan.martinez at ecc.es Thu Jan 26 10:27:36 2006 From: hernan.martinez at ecc.es (=?US-ASCII?Q?Hernan_Martinez?=) Date: Thu, 26 Jan 2006 10:27:36 +0100 Subject: [Python.NET] Any plans for supporting CLR2.0? In-Reply-To: <7465b6170601252001w47e37150w73e21621b1634ba6@mail.gmail.com> Message-ID: >> I must say that Python.NET feels like an approach I would use more >> than IronPython. > > I am second to this opinion. If I do not want\need to embed Python > within CLR or .NET > application I definitely do not want to install and use an other > Python interpreter. CPython interpreter works fine. There's also the fact that IronPython is too young and requires .NET 2.0. For people who already have a mature application, use 1.1, and/or is already in production IMHO Python.NET is the way to go. -H. From Pierre.Zeeman at psitek.com Thu Jan 26 12:16:23 2006 From: Pierre.Zeeman at psitek.com (Pierre Zeeman) Date: Thu, 26 Jan 2006 13:16:23 +0200 Subject: [Python.NET] packaging pythondotnet with py2exe, redux Message-ID: Hi, I'd just like to add a little bit more info to the exchange reproduced below. You also need to explicitly "import CLR" prior to importing specific parts of the CLR. Py2exe can't resolve the implicit import contained in, e.g., "import CLR.System.Windows.Forms as WinForms" without the preceding reference. Note also that py2exe will complain about certain CLR modules being missing at the end of the compilation process. These warnings can be ignored. Rgds Pierre p.s. note also that while py2exe will find and copy CLR.dll to the dist directory, it does not do so for Python.Runtime.dll and you need to do this manually... >For windows, you need to include CLR.dll and PythonRuntime.dll >(as well as anything from the standard Python distro that you >use, of course). > >HTH, > >Brian Lloyd brian at zope.com > >> -----Original Message----- >> >> Apologies if this has been answered before, but what modules/DLLs are >> needed to package, using py2exe, a python app that uses pythondotnet? >> >> Thank you so much, >> >> marsal