From swpark71 at gmail.com Wed May 1 00:06:28 2013 From: swpark71 at gmail.com (Seungweon Park) Date: Tue, 30 Apr 2013 15:06:28 -0700 Subject: [Python.NET] How to use python object from powershell drectly? Message-ID: Hi, I'd like to call python method, or receive python object (method) directly from powershell. Is it possible using python.net? Thanks, Spark. -------------- next part -------------- An HTML attachment was scrubbed... URL: From swpark71 at gmail.com Wed May 1 17:04:05 2013 From: swpark71 at gmail.com (Seungweon Park) Date: Wed, 1 May 2013 08:04:05 -0700 Subject: [Python.NET] How to use python object from powershell drectly? In-Reply-To: References: Message-ID: In order to test if it is possible, I try to load assembly Python.Runtime.dll from Powershell. Once open powershell prompt, and tried to load Python.Runtime.dll, but I got following error in Windows 2008 R2 x64. I compiled pythonnet with 32bit and Pyton 2.7.3 (32bit) installed. (nPython.exe works fine in dos propmpt though, copied nPython.exe, Python.Runtime.dll, clr.pyd into C:\Python27). Is there something I missed? or anything I need to check? looks like I need to load some assemblies before Python.Runtime.dll, or environment settings to load Python 2.7.3. Thank you, Spark. C:\Python27>powershell Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved. PS C:\Python27> [System.Reflection.Assembly]::LoadFrom("C:\Python27\Python.Runtime.dll") Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Python27\Python.Runtime.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format." At line:1 char:39 + [System.Reflection.Assembly]::LoadFrom <<<< ("C:\Python27\Python.Runtime.dll") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException PS C:\Python27> On Tue, Apr 30, 2013 at 3:06 PM, Seungweon Park wrote: > Hi, > > I'd like to call python method, or receive python object (method) directly > from powershell. Is it possible using python.net? > > Thanks, > Spark. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jojo.maquiling at kadjo.org Fri May 24 03:40:59 2013 From: jojo.maquiling at kadjo.org (Jojo Maquiling) Date: Fri, 24 May 2013 09:40:59 +0800 Subject: [Python.NET] I need to use C# list as an object for one of my controls Message-ID: Here is the issue that i need to address: * * *# My declaration is just fine here * >>> class person(System.Object): def __init__(self,fname,lname): self.Firstname = fname self.Lastname = lname *# adding a value also goes fine. * >>> j = person('jojo','maquiling') >>> j <__main__.person object at 0x029E7C88> >>> j.Firstname 'jojo' >>> j.Lastname 'maquiling' *#but then when i use listing and print it, here comes the problem* * * >>> listing = List[person]() >>> listing >>> listing.Add(person('pepe','smith')) >>> for l in listing: print l.Firstname *Traceback (most recent call last):* * File "", line 2, in * * print l.Firstname* *AttributeError: 'Object' object has no attribute 'Firstname'* * * Can any body help me on how to do this properly? Thanks and best regards, Jojo Maquiling * * * * -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad at fie.us Fri May 24 06:00:17 2013 From: brad at fie.us (brad at fie.us) Date: Fri, 24 May 2013 00:00:17 -0400 Subject: [Python.NET] I need to use C# list as an object for one of my controls In-Reply-To: References: Message-ID: <9CB30B68-D263-4C9D-96A6-7EABC14ECF32@fie.us> What exactly are you trying to do? It looks like you are trying to create a class in python that inherits from .net's System.Object, rather than python's object. But then you treat it as a dynamic object, which it really isn't. And then you try and treat it as a statically typed object, which it doesn't seem t be either really, now that you've treated it as dynamic in python. What is the intent? Do you mean to create a dynamic object that both .net and python treat as a dynamically typed object? On May 23, 2013, at 9:40 PM, Jojo Maquiling wrote: > Here is the issue that i need to address: > > > # My declaration is just fine here > > >>> class person(System.Object): > def __init__(self,fname,lname): > self.Firstname = fname > self.Lastname = lname > > # adding a value also goes fine. > >>> j = person('jojo','maquiling') > >>> j > <__main__.person object at 0x029E7C88> > >>> j.Firstname > 'jojo' > >>> j.Lastname > 'maquiling' > > #but then when i use listing and print it, here comes the problem > > >>> listing = List[person]() > >>> listing > > >>> listing.Add(person('pepe','smith')) > >>> for l in listing: > print l.Firstname > > Traceback (most recent call last): > File "", line 2, in > print l.Firstname > AttributeError: 'Object' object has no attribute 'Firstname' > > > Can any body help me on how to do this properly? > Thanks and best regards, > > Jojo Maquiling > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------- next part -------------- An HTML attachment was scrubbed... URL: From jojo.maquiling at kadjo.org Fri May 24 06:07:45 2013 From: jojo.maquiling at kadjo.org (Jojo Maquiling) Date: Fri, 24 May 2013 12:07:45 +0800 Subject: [Python.NET] I need to use C# list as an object for one of my controls In-Reply-To: <9CB30B68-D263-4C9D-96A6-7EABC14ECF32@fie.us> References: <9CB30B68-D263-4C9D-96A6-7EABC14ECF32@fie.us> Message-ID: Actually i'm just trying to use a .net System.Object List with this one - http://objectlistview.sourceforge.net/cs/index.html. I like the way the grid is displayed on that objectlistview so i'm trying to experiment and dispay, but what i get is just an empty row. Here is the snippet of my code. def LoadRecord(self,sender,e): listing = List[person]() listing.Add(person('jojo','maquiling')) listing.Add(person('gary','granada')) self._objectListView1.SetObjects(listing) A datagrid is good,I have used it, but then i just want to figure out also if its possible for me to use this ObjectListView control on my application. Thanks and best regards. Jojo Maquiling On Fri, May 24, 2013 at 12:00 PM, brad at fie.us wrote: > What exactly are you trying to do? It looks like you are trying to create > a class in python that inherits from .net's System.Object, rather than > python's object. But then you treat it as a dynamic object, which it > really isn't. And then you try and treat it as a statically typed object, > which it doesn't seem t be either really, now that you've treated it as > dynamic in python. What is the intent? Do you mean to create a dynamic > object that both .net and python treat as a dynamically typed object? > > On May 23, 2013, at 9:40 PM, Jojo Maquiling > wrote: > > Here is the issue that i need to address: > > * > * > *# My declaration is just fine here * > > >>> class person(System.Object): > def __init__(self,fname,lname): > self.Firstname = fname > self.Lastname = lname > > *# adding a value also goes fine. * > >>> j = person('jojo','maquiling') > >>> j > <__main__.person object at 0x029E7C88> > >>> j.Firstname > 'jojo' > >>> j.Lastname > 'maquiling' > > *#but then when i use listing and print it, here comes the problem* > * > * > >>> listing = List[person]() > >>> listing > PublicKeyToken=b77a5c561934e089]] object at 0x029E7C60> > >>> listing.Add(person('pepe','smith')) > >>> for l in listing: > print l.Firstname > > *Traceback (most recent call last):* > * File "", line 2, in * > * print l.Firstname* > *AttributeError: 'Object' object has no attribute 'Firstname'* > * > * > > Can any body help me on how to do this properly? > Thanks and best regards, > > Jojo Maquiling > * > * > * > * > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dierickx3 at yahoo.com Thu May 23 22:12:24 2013 From: dierickx3 at yahoo.com (Tom Dierickx) Date: Thu, 23 May 2013 13:12:24 -0700 (PDT) Subject: [Python.NET] Python.NET "Glitch" Solved Message-ID: <1369339944.23724.YahooMailNeo@web142606.mail.bf1.yahoo.com> Brian, Just wanted to share something with you in case it helps the cause. I was having real trouble getting a custom assembly compiled against 4.0 framework to import. Technically, it was the open source EPPlus.dll library and I could add it fine via clr.AddReference("EPPlus") but the import step failed saying "No module named OfficeOpenXml". Here's where it gets strange ... the *exact* same source code against the *exact* same target framework 4.0 created slightly different .dll's when compiled from VS2010 vs 2012. The one compiled using Vs2010 had no problems being imported into python.net but the Vs2012 exhibited the behavior above. It turns out that there's a subtle thing going on: 1) Your ScanAssembly() method inside assemblymanager.cs iterates over all the types in the assembly to deduce namespaces and adds them to a new dictionary object (ok so far) 2) But the 2012-compiled ,dll and the 2010-compiled .dll seem to have their assembly.GetTypes() in slightly different order and your extra "if (t.IsGenericTypeDefinition) {GenericUtil.Register(t);}" piece of this?ScanAssembly() method was running into some generic types w/o a namespace in the 2012-compiled .dll "sooner" than they're listed in the 2010-compiled .dll and blowing things up before any namespaces could be added To make a long story short, here's what I changed and then all worked again for me: BEFORE: if (t.IsGenericTypeDefinition) { ? ?GenericUtil.Register(t); } AFTER: if (ns != null && t.IsGenericTypeDefinition) { ? ?GenericUtil.Register(t); } By the way, I was able to compile a new "Python.Runtime.dll" and "clr.pyd" (aka, clrmodule.dll) against 4.5 using Visual Studio 2012 without any problems and load in said EPPLus.dll compiled against 4.5 within my python script. I'm not sure how robust your module is against a heavy RAM/CPU/IO load, but it's definitely intriguing to be able to tap into .NET 4.0/4.5 assemblies from python!! Cheers, Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From uffe.kousgaard at routeware.dk Fri May 24 22:23:21 2013 From: uffe.kousgaard at routeware.dk (Uffe Kousgaard) Date: Fri, 24 May 2013 22:23:21 +0200 Subject: [Python.NET] missing constructor Message-ID: <519FCC39.5030503@routeware.dk> First of all, thank you for a great library. I have run into an issue of an "object" in my assembly that do not have a constructor (other than "void"). The object is called TFloatPoint and has 2 public fields x and y. At first we used this: myPoint = TFloatPoint(), but that didn't work due to lack of matching constructor. Then I replaced it with a method call that returned a TFloatPoint result and that works. But for another class, I do not currently have any methods returning such an instance. Is there any generally working method, other than creating dummy methods returning the desired class / type? I'm using this one with Python 2.7.2: pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip Kind regards Uffe Kousgaard From jojo.maquiling at kadjo.org Sat May 25 03:18:16 2013 From: jojo.maquiling at kadjo.org (Jojo Maquiling) Date: Sat, 25 May 2013 09:18:16 +0800 Subject: [Python.NET] I need to use C# list as an object for one of my controls In-Reply-To: References: <9CB30B68-D263-4C9D-96A6-7EABC14ECF32@fie.us> Message-ID: Ok Thanks Brad for the reply. I'm just confused really on that static and dynamic thing that i have experimented on it via console. I have figure it out now on how to use that objectlistview. I've just created a datatable and fill data on it and use the DataListView which is part of the ObjectListView library. Python dot net is really a great software. On Fri, May 24, 2013 at 12:07 PM, Jojo Maquiling wrote: > Actually i'm just trying to use a .net System.Object List with this one - > http://objectlistview.sourceforge.net/cs/index.html. I like the way the > grid is displayed on that objectlistview so i'm trying to experiment and > dispay, but what i get is just an empty row. > > Here is the snippet of my code. > > def LoadRecord(self,sender,e): > listing = List[person]() > listing.Add(person('jojo','maquiling')) > listing.Add(person('gary','granada')) > self._objectListView1.SetObjects(listing) > > > A datagrid is good,I have used it, but then i just want to figure out also > if its possible for me to use this ObjectListView control on my application. > > Thanks and best regards. > > Jojo Maquiling > > > On Fri, May 24, 2013 at 12:00 PM, brad at fie.us wrote: > >> What exactly are you trying to do? It looks like you are trying to >> create a class in python that inherits from .net's System.Object, rather >> than python's object. But then you treat it as a dynamic object, which it >> really isn't. And then you try and treat it as a statically typed object, >> which it doesn't seem t be either really, now that you've treated it as >> dynamic in python. What is the intent? Do you mean to create a dynamic >> object that both .net and python treat as a dynamically typed object? >> >> On May 23, 2013, at 9:40 PM, Jojo Maquiling >> wrote: >> >> Here is the issue that i need to address: >> >> * >> * >> *# My declaration is just fine here * >> >> >>> class person(System.Object): >> def __init__(self,fname,lname): >> self.Firstname = fname >> self.Lastname = lname >> >> *# adding a value also goes fine. * >> >>> j = person('jojo','maquiling') >> >>> j >> <__main__.person object at 0x029E7C88> >> >>> j.Firstname >> 'jojo' >> >>> j.Lastname >> 'maquiling' >> >> *#but then when i use listing and print it, here comes the problem* >> * >> * >> >>> listing = List[person]() >> >>> listing >> > PublicKeyToken=b77a5c561934e089]] object at 0x029E7C60> >> >>> listing.Add(person('pepe','smith')) >> >>> for l in listing: >> print l.Firstname >> >> *Traceback (most recent call last):* >> * File "", line 2, in * >> * print l.Firstname* >> *AttributeError: 'Object' object has no attribute 'Firstname'* >> * >> * >> >> Can any body help me on how to do this properly? >> Thanks and best regards, >> >> Jojo Maquiling >> * >> * >> * >> * >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> http://mail.python.org/mailman/listinfo/pythondotnet >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: