From guy at r-e-d.co.nz Sun Sep 11 14:38:12 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Mon, 12 Sep 2005 00:38:12 +1200 Subject: [Python.NET] binding python objects to treenodes Message-ID: <43242534.5050405@r-e-d.co.nz> Hello, Is there a way to bind a python object to a treeView node? I have the following treenode based class: class dataNode(WinForms.TreeNode): def __init__(self,name,total): self.Text = name self.Total = total And I add the node as such: self.treeView1.Nodes.Add(dataNode("testnode",3)) But when I try and access the attributes it doesn't work? for node in self.treeView1.Nodes: print node.Total Or should I keep the nodes in a list and access by index? Any help appeciated. Guy From guy at r-e-d.co.nz Mon Sep 12 05:38:55 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Mon, 12 Sep 2005 15:38:55 +1200 Subject: [Python.NET] winForms, threading and dragdrop ? Message-ID: <4324F84F.5040709@r-e-d.co.nz> From the attached code.With AllowDrop = True I get a .NET error as follows: System.InvalidOperationException: DragDrop registration failed. ---> System.Threading.ThreadStateException: The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. From googling I need to set ApartmentState.STA. But this is readonly. How do I set STA correctly in Python for .NET? Any thoughts appeciated. Guy -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: DnD_Tree2.py Url: http://mail.python.org/pipermail/pythondotnet/attachments/20050912/d5dacdb2/DnD_Tree2.asc From brian at zope.com Mon Sep 12 15:18:51 2005 From: brian at zope.com (Brian Lloyd) Date: Mon, 12 Sep 2005 09:18:51 -0400 Subject: [Python.NET] winForms, threading and dragdrop ? In-Reply-To: <4324F84F.5040709@r-e-d.co.nz> References: <4324F84F.5040709@r-e-d.co.nz> Message-ID: Hi Guy -- as far as I know, you can't change the thread state after any COM or interop calls have happened (and Python for .NET is all interop...). What you probably need to do is set the attribute in the C# 'embedding' application before initializing the python engine (or making any other interp calls). On Mon, 12 Sep 2005 15:38:55 +1200 Guy Robinson wrote: > From the attached code.With AllowDrop = True I get a > .NET error as follows: > > System.InvalidOperationException: DragDrop registration > failed. ---> System.Threading.ThreadStateException: The > current thread must set to Single Thread Apartment (STA) > mode before OLE calls can be made. Ensure that your Main > function has STAThreadAttribute marked on it. > > From googling I need to set ApartmentState.STA. But this > is readonly. How do I > set STA correctly in Python for .NET? > > Any thoughts appeciated. > > Guy > From guy at r-e-d.co.nz Mon Sep 12 22:22:39 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Tue, 13 Sep 2005 08:22:39 +1200 Subject: [Python.NET] winForms, threading and dragdrop ? In-Reply-To: References: <4324F84F.5040709@r-e-d.co.nz> Message-ID: <4325E38F.9060507@r-e-d.co.nz> Cheers Brian. Interestingly the script runs OK from within PythonWin. I guess PythonWin must be setting STA correctly but the python console doesn't? Guy Brian Lloyd wrote: > Hi Guy -- as far as I know, you can't change the thread > state after any COM or interop calls have happened (and > Python for .NET is all interop...). > > What you probably need to do is set the attribute in > the C# 'embedding' application before initializing the > python engine (or making any other interp calls). > > On Mon, 12 Sep 2005 15:38:55 +1200 > Guy Robinson wrote: > >> From the attached code.With AllowDrop = True I get a >>.NET error as follows: >> >>System.InvalidOperationException: DragDrop registration >>failed. ---> System.Threading.ThreadStateException: The >>current thread must set to Single Thread Apartment (STA) >>mode before OLE calls can be made. Ensure that your Main >>function has STAThreadAttribute marked on it. >> >> From googling I need to set ApartmentState.STA. But this >>is readonly. How do I >>set STA correctly in Python for .NET? >> >>Any thoughts appeciated. >> >>Guy >> > > > > > -- A ReDGAS Project Robinson eDesign, P/F: +64 7 866 0626 Rings Beach, M: 021 238 0839 -ltd coverage RD2, E: guy at r-e-d.co.nz Whitianga. New Zealand The contents of this e-mail maybe CONFIDENTIAL OR LEGALLY PRIVILEGED, & is intended only for the persons named above. If this e-mail is not addressed to you, you must not use, read, distribute or copy this document. If you have received this document by mistake, please call us and destroy the original. Thank you From meddington at gmail.com Thu Sep 15 02:07:09 2005 From: meddington at gmail.com (Michael Eddington) Date: Wed, 14 Sep 2005 17:07:09 -0700 Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 Message-ID: <2db0cefa05091417073ccaaa0a@mail.gmail.com> Anyone else out there started to mess with Python.NET on the 2.0 platform? One of the first hurtles was the output from ildasm does not always place the method name on the next line, causing callconvutil to place the modopt in the wrong place. I've added a regex in to check for and split the method line if the function name is found. mike -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050914/a4572334/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: callconvutil.cs Url: http://mail.python.org/pipermail/pythondotnet/attachments/20050914/a4572334/callconvutil.pot From Roark.Hennessy at teleatlas.com Thu Sep 15 20:50:15 2005 From: Roark.Hennessy at teleatlas.com (Roark Hennessy) Date: Thu, 15 Sep 2005 14:50:15 -0400 Subject: [Python.NET] looking for docs on ironpython for .NET Message-ID: anyone know where i can get some docs on iron python? i've got some dumb questions and was looking for answers. Here's the first question: 1. i've tried and like active state's visual python. then i heard of this iron python beta thats fast and integrated w/ .NET. I downloaded but don't know how to get it to work inside the .NET IDE. ??? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050915/f4c7865e/attachment.htm From meddington at gmail.com Thu Sep 15 21:00:03 2005 From: meddington at gmail.com (Michael Eddington) Date: Thu, 15 Sep 2005 12:00:03 -0700 Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 Message-ID: <2db0cefa05091512002c49d4b3@mail.gmail.com> Anyone else out there started to mess with Python.NET on the 2.0 platform? One of the first hurtles was the output from ildasm does not always place the method name on the next line, causing callconvutil to place the modopt in the wrong place. I've added a regex in to check for and split the method line if the function name is found. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: callconvutil.cs Url: http://mail.python.org/pipermail/pythondotnet/attachments/20050915/429bd952/callconvutil.asc From meddington at gmail.com Fri Sep 16 02:22:02 2005 From: meddington at gmail.com (Michael Eddington) Date: Thu, 15 Sep 2005 17:22:02 -0700 Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 Message-ID: <2db0cefa05091517225bf8578a@mail.gmail.com> Anyone else out there started to mess with Python.NET on the 2.0 platform? One of the first hurtles was the output from ildasm does not always place the method name on the next line, causing callconvutil to place the modopt in the wrong place. I've added a regex in to check for and split the method line if the function name is found. Currently getting lots of access violation exceptions. mike Replace ReadMethod with the following: public void ReadMethod(string line) { Regex findMethod = new Regex(@"^(\s*.method\s.*\s)([^\s()]+\([^()]*(?:,|\)\s.*))$"); ArrayList lines = new ArrayList(); string mline = line; string data; string buff; while ((data = reader.ReadLine()) != null) { buff = data.Trim(); if (buff.StartsWith(ccAttr)) { // BUG: mline may have method name in it already which breaks // things. This is mostly seen in .NET 2.0. // Example: .method public hidebysig static int32 tp_descr_set(native int ds, if (findMethod.IsMatch(mline)) { // method name is on same line as .method. Need to insert // modOpt prior to method name. Match match = findMethod.Match(mline); writer.WriteLine(match.Groups[1].Value + " "); writer.WriteLine(modOpt + " "); writer.WriteLine(match.Groups[2].Value); } else { writer.WriteLine(mline); writer.WriteLine(modOpt); } WriteBuffer(lines); writer.WriteLine(data); return; } else if (buff.StartsWith("} // end of method")) { writer.WriteLine(mline); WriteBuffer(lines); writer.WriteLine(data); return; } lines.Add(data); } } From jvm_cop at spamcop.net Fri Sep 16 04:51:51 2005 From: jvm_cop at spamcop.net (J. Merrill) Date: Thu, 15 Sep 2005 22:51:51 -0400 Subject: [Python.NET] looking for docs on ironpython for .NET In-Reply-To: Message-ID: <4.3.2.7.2.20050915225042.05a446b8@mail.comcast.net> You want to be on the IronPython mail list. List-Subscribe: , At 02:50 PM 9/15/2005, Roark Hennessy wrote >anyone know where i can get some docs on iron python? i've got some dumb questions and was looking for answers. Here's the first question: >1. i've tried and like active state's visual python. then i heard of this iron python beta thats fast and integrated w/ .NET. I downloaded but don't know how to get it to work inside the .NET IDE. ??? J. Merrill / Analytical Software Corp From brian at zope.com Fri Sep 16 15:29:21 2005 From: brian at zope.com (Brian Lloyd) Date: Fri, 16 Sep 2005 09:29:21 -0400 Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 In-Reply-To: <2db0cefa05091517225bf8578a@mail.gmail.com> Message-ID: Thanks for the patch! I've been slammed lately and haven't had time to wrap up 1.0 and make the 2.x branch ;( Any details you can post on the access violations would be helpful too (to me, anyway). Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces+brian=zope.com at python.org > [mailto:pythondotnet-bounces+brian=zope.com at python.org]On Behalf Of > Michael Eddington > Sent: Thursday, September 15, 2005 7:22 PM > To: pythondotnet at python.org > Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 > > > Anyone else out there started to mess with Python.NET on the 2.0 > platform? One of the first hurtles was the output from ildasm does > not always place the method name on the next line, causing > callconvutil to place the modopt in the wrong place. I've added a > regex in to check for and split the method line if the function name > is found. > > Currently getting lots of access violation exceptions. > > mike > > Replace ReadMethod with the following: > > public void ReadMethod(string line) > { > Regex findMethod = new > Regex(@"^(\s*.method\s.*\s)([^\s()]+\([^()]*(?:,|\)\s.*))$"); > > ArrayList lines = new ArrayList(); > string mline = line; > > string data; > string buff; > > while ((data = reader.ReadLine()) != null) > { > buff = data.Trim(); > if (buff.StartsWith(ccAttr)) > { > // BUG: mline may have method name in it already > which breaks > // things. This is mostly seen in .NET 2.0. > // Example: .method public hidebysig static int32 > tp_descr_set(native int ds, > if (findMethod.IsMatch(mline)) > { > // method name is on same line as .method. > Need to insert > // modOpt prior to method name. > Match match = findMethod.Match(mline); > > writer.WriteLine(match.Groups[1].Value + " "); > writer.WriteLine(modOpt + " "); > writer.WriteLine(match.Groups[2].Value); > } > else > { > writer.WriteLine(mline); > writer.WriteLine(modOpt); > } > > WriteBuffer(lines); > writer.WriteLine(data); > return; > } > else if (buff.StartsWith("} // end of method")) > { > writer.WriteLine(mline); > WriteBuffer(lines); > writer.WriteLine(data); > return; > } > lines.Add(data); > } > } > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From glc at well.com Mon Sep 19 22:50:17 2005 From: glc at well.com (Greg Chapman) Date: Mon, 19 Sep 2005 20:50:17 +0000 (UTC) Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 References: <2db0cefa05091512002c49d4b3@mail.gmail.com> Message-ID: Michael Eddington wrote: > Anyone else out there started to mess with Python.NET on the 2.0 > platform? One of the first hurtles was the output from ildasm does > not always place the method name on the next line, causing > callconvutil to place the modopt in the wrong place. I've added a > regex in to check for and split the method line if the function name > is found. Here's something I just discovered. You can now (in .NET 2.0) apply the UnmanagedFunctionPointer attribute to delegate types to get them to work as cdecl. For example: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate IntPtr UnaryFunc(IntPtr ob); >From what I can tell, that delegate type is compatible with any managed method with the right signature. When called from unmanaged code, such delegates will use the cdecl convention (this must be done in some kind of thunk, since the method itself still uses the normal .NET calling convention). Anyway, the upshot is it looks like you can apply that attribute to all the CallConvCDecl delegates in Interop.cs (removing the CallConvCDecl attribute, since it's not needed), and then not need callconvutil at all. -- Greg Chapman From brian at zope.com Tue Sep 20 21:04:20 2005 From: brian at zope.com (Brian Lloyd) Date: Tue, 20 Sep 2005 15:04:20 -0400 Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0 In-Reply-To: Message-ID: Hee hee - this is good news. I'm looking forward to getting rid of that horrible IL hack... ;) Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces at python.org > [mailto:pythondotnet-bounces at python.org]On Behalf Of Greg Chapman > Sent: Monday, September 19, 2005 3:50 PM > To: pythondotnet at python.org > Subject: Re: [Python.NET] Updates to callconvutil.cs for .NET 2.0 > > > Michael Eddington wrote: > > > Anyone else out there started to mess with Python.NET on the 2.0 > > platform? One of the first hurtles was the output from ildasm does > > not always place the method name on the next line, causing > > callconvutil to place the modopt in the wrong place. I've added a > > regex in to check for and split the method line if the function name > > is found. > > Here's something I just discovered. You can now (in .NET 2.0) apply > the UnmanagedFunctionPointer attribute to delegate types to get them to > work as cdecl. For example: > > [UnmanagedFunctionPointer(CallingConvention.Cdecl)] > public delegate IntPtr UnaryFunc(IntPtr ob); > > >From what I can tell, that delegate type is compatible with any managed > method with the right signature. When called from unmanaged code, such > delegates will use the cdecl convention (this must be done in some kind > of thunk, since the method itself still uses the normal .NET calling > convention). > > Anyway, the upshot is it looks like you can apply that attribute to all > the CallConvCDecl delegates in Interop.cs (removing the CallConvCDecl > attribute, since it's not needed), and then not need callconvutil at > all. > > -- > Greg Chapman > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From Aaron_Stubbs at symantec.com Wed Sep 21 00:28:09 2005 From: Aaron_Stubbs at symantec.com (Aaron Stubbs) Date: Tue, 20 Sep 2005 15:28:09 -0700 Subject: [Python.NET] PythonNet and .NET Framework 2.0 Message-ID: Is there any way to use PythonNet with the 2.0 version of the .Net framework? The assemblies we're working with will for the test harness we're creating will all be .Net 2.0 assemblies, so if there's anything we can do to get PythonNet working with them I'd be all ears. I did note that this will be a specific feature (as outlined by Brian) for the PythonNet 2.x releases, but that appears to be a little way off... Thanks in advance for you time. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050920/da42c970/attachment.htm