From roman.yakovenko at gmail.com Wed Jun 1 07:11:21 2005 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 1 Jun 2005 08:11:21 +0300 Subject: [Python.NET] Small improvment for CLR exceptions In-Reply-To: References: <206CE615-18B3-4E8F-B8F9-F2E9EFBE76AA@redivi.com> Message-ID: <7465b61705053122116ba2bceb@mail.gmail.com> On 5/31/05, Brian Lloyd wrote: > Hi all - > > So to summarize this thread: we want to make __str__ of a CLR > exception return self.Message, right? That would seem to match > the behavior of the std Python exceptions. > > > Brian Lloyd brian at zope.com > V.P. Engineering 540.361.1716 > Zope Corporation http://www.zope.com > > Yes. Thanks for your efforts. Roman From guy at r-e-d.co.nz Wed Jun 1 13:40:16 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Wed, 01 Jun 2005 23:40:16 +1200 Subject: [Python.NET] ListView bug? Message-ID: <429D9EA0.5000100@r-e-d.co.nz> Find attached script for a windows.Form. Is this a bug? When loading the data into the listview from a list of tuples: data = [("one","test one"),("two","test two"), ("three","test three")] for item in data: temp = WF.ListViewItem(item[0]) temp.SubItems.Add(item[1]) self.listView.Items.Add(temp) The rows are filled with the first and second characters of the first string rather than the relevant tuple strings. Winforms is pretty cool otherwise. Guy -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: scriptForm.py Url: http://mail.python.org/pipermail/pythondotnet/attachments/20050601/82cbcf90/scriptForm.ksh From guy at r-e-d.co.nz Wed Jun 1 14:05:02 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Thu, 02 Jun 2005 00:05:02 +1200 Subject: [Python.NET] ListView bug? In-Reply-To: <429D9EA0.5000100@r-e-d.co.nz> References: <429D9EA0.5000100@r-e-d.co.nz> Message-ID: <429DA46E.8000900@r-e-d.co.nz> Ok, my fault :-( This works: data = [("one","test one"),("two","test two"), ("three","test three")] for index in range(len(data)): temp = WF.ListViewItem(str(index)) temp.Text = data[index][0] temp.SubItems.Add(data[index][1]) self.listView.Items.Add(temp) Guy Guy Robinson wrote: > Find attached script for a windows.Form. Is this a bug? When loading the > data into the listview from a list of tuples: > > data = [("one","test one"),("two","test two"), ("three","test three")] > for item in data: > temp = WF.ListViewItem(item[0]) > temp.SubItems.Add(item[1]) > self.listView.Items.Add(temp) > > The rows are filled with the first and second characters of the first > string rather than the relevant tuple strings. > > Winforms is pretty cool otherwise. > > Guy > > > ------------------------------------------------------------------------ > > import CLR > from CLR import System > > import CLR.System.Windows.Forms as WF > from CLR.System.Drawing import Size, Point, Color > > class ScriptForm(WF.Form): > """A simple hello world app that demonstrates the essentials of > WF programming and event-based programming in Python.""" > > def __init__(self): > self.Text = "Python scripting for the Revit API" > #self.AutoScaleBaseSize = Size(5, 13) > self.ClientSize = Size(500, 300) > h = WF.SystemInformation.CaptionHeight > self.MinimumSize = Size(300, (100 + h)) > self.FormBorderStyle = WF.FormBorderStyle.FixedDialog > self.MinimizeBox = False > self.MaximizeBox = False > self.StartPosition = WF.FormStartPosition.CenterScreen > self.components = System.ComponentModel.Container() > > # Create the ListView > self.listView = WF.ListView() > self.listView.Location = Point(5,5) > self.listView.Width = 370 > self.listView.Height = self.ClientSize.Height-10 > self.listView.TabIndex = 0 > self.formatLV() > self.loaddata() > > # Create the run button > self.runBut = WF.Button() > self.runBut.Location = Point(400, 100) > self.runBut.BackColor = Color.GreenYellow > self.runBut.TabIndex = 1 > self.runBut.Text = "Run Script" > > # Create the Cancel button > self.CanBut = WF.Button() > self.CanBut.Location = Point(400, 150) > self.CanBut.TabIndex = 2 > self.CanBut.Text = "Cancel" > > # Register the event handlers > self.runBut.Click += self.runScript_Click > self.CanBut.Click += self.Cancel_Click > > # Add the controls to the form > self.Controls.Add(self.listView) > self.Controls.Add(self.runBut) > self.Controls.Add(self.CanBut) > > def runScript_Click(self, sender, args): > """ Get and Run the selected script""" > WF.MessageBox.Show("Run script") > #return "script" > > def Cancel_Click(self, sender, args): > """Cancel don't run anything""" > #return "cancel" > self.components.Dispose() > WF.Form.Dispose(self) > self.Close() > > def formatLV(self): > self.listView.View = WF.View.Details > self.listView.LabelEdit = False > self.listView.AllowColumnReorder = False > self.listView.GridLines = True > self.listView.FullRowSelect = True > self.listView.Sorting = WF.SortOrder.Ascending > #now do columns > self.listView.Columns.Add("Script Name", 100,WF.HorizontalAlignment.Left) > self.listView.Columns.Add("Description", 266,WF.HorizontalAlignment.Left) > > def loaddata(self): > data = [("one","test one"),("two","test two"), ("three","test three")] > for item in data: > temp = WF.ListViewItem(item[0]) > temp.SubItems.Add(item[1]) > self.listView.Items.Add(temp) > > def run(self): > WF.Application.Run(self) > self.components.Dispose() > WF.Form.Dispose(self) > self.Close() > > def main(): > ScriptForm().run() > > > if __name__ == '__main__': > main() > > > > ------------------------------------------------------------------------ > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -- 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 From stan at phidani.be Thu Jun 2 14:35:14 2005 From: stan at phidani.be (Stan Pinte) Date: Thu, 02 Jun 2005 12:35:14 +0000 Subject: [Python.NET] Small improvment for CLR exceptions In-Reply-To: References: Message-ID: <429EFD02.1060802@phidani.be> Brian Lloyd wrote: >Hi all - > >So to summarize this thread: we want to make __str__ of a CLR >exception return self.Message, right? That would seem to match >the behavior of the std Python exceptions. > > > I would add the following: __str__ should display self.Message, then self.StackTrace....to be able to immediately point out the error in C# code... No? Stan. From brian at zope.com Sun Jun 5 18:15:09 2005 From: brian at zope.com (Brian Lloyd) Date: Sun, 5 Jun 2005 12:15:09 -0400 Subject: [Python.NET] Announce: Python for .NET 1.0 RC2 released Message-ID: Hi all - I'm happy to announce the release of Python for .NET 1.0 RC2. You can download it from: http://www.zope.org/Members/Brian/PythonNet Highlights of this release: - Changed some uses of Finalize as a static method name that confused the Mono compiler and people reading the code. Note that this may be a breaking change if anyone was calling PythonEngine.Finalize(). If so, you should now use PythonEngine.Shutdown(). - Tweaked assembly lookup to ensure that assemblies can be found in the current working directory, even after changing directories using things like os.chdir() from Python. - Fixed some incorrect finalizers (thanks to Greg Chapman for the report) that may have caused some threading oddities. - Tweaked support for out and ref parameters. If a method has a return type of void and a single ref or out parameter, that parameter will be returned as the result of the method. This matches the current behavior of IronPython and makes it more likely that code can be moved between Python for .NET and IP in the future. - Refactored part of the assembly manager to remove a potential case of thread-deadlock in multi-threaded applications. - Added a __str__ method to managed exceptions that returns the Message attribute of the exception and the StackTrace (if available). Thanks to all who have sent in issue reports, patches and suggestions for this and past releases. Enjoy! ;) Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From scl at protronic.com Tue Jun 7 14:50:02 2005 From: scl at protronic.com (COOL Steven) Date: Tue, 7 Jun 2005 14:50:02 +0200 Subject: [Python.NET] Error Pythonnet Message-ID: <1FE21036A81C804DBD1A5EEAAA99FD1BCE453D@pic01s51.picanol> Hello I'm trying to use Pythonnet put when I try to start the python.exe I get an error.(see figure) I have tried to run the console application from my VS environment. And tried to debug it. The exception is comming in this function (see Runtime.cs): [DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl, ExactSpelling=true, CharSet=CharSet.Ansi)] internal unsafe static extern IntPtr PyTuple_GetItem(IntPtr pointer, int index); Regards Steven Cool Development Engineer Protronic NV Rozendaalstraat 53 BE-8900 Ieper P: + 32 (0)57 22 47 09 E-mail: scl at protronic.com **** DISCLAIMER **** The contents of this e-mail are intended for the named addressee only. It contains information which may be confidential and which may also be privileged. Unless you are the named addressee (or authorised to receive for the addressee) you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. Further, we make every effort to keep our network free from viruses. However, you do need to verify that this email and any attachments are free of viruses as we can take no responsibility for any computer virus which might be transferred by way of this e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050607/cafc1d07/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/bmp Size: 254814 bytes Desc: Outlook.bmp Url : http://mail.python.org/pipermail/pythondotnet/attachments/20050607/cafc1d07/attachment-0001.bmp From stan at phidani.be Tue Jun 14 18:19:11 2005 From: stan at phidani.be (Stan Pinte) Date: Tue, 14 Jun 2005 16:19:11 +0000 Subject: [Python.NET] attribute semantics question Message-ID: <42AF037F.2060308@phidani.be> hello, It is currently possible to add new attributes using the standard python notation, to existing C# objects. like that: #C is C# class cInstance = C() c.NewProperty = "hop" #NewProperty Property is not defined at the C# level. My questions: 1: is this the desired/expected behaviour? 2: is this usable at C# level (I should test, I suppose, using introspection ;-) --> I find it sometimes annoying not to know that I am defining a new attribute, because such dynamicity is not expected at C# level (well at python level). thanks a lot for your help, Stan. From brian at zope.com Wed Jun 15 15:38:13 2005 From: brian at zope.com (Brian Lloyd) Date: Wed, 15 Jun 2005 09:38:13 -0400 Subject: [Python.NET] attribute semantics question In-Reply-To: <42AF037F.2060308@phidani.be> Message-ID: > It is currently possible to add new attributes using the standard python > notation, to existing C# objects. > > like that: > > #C is C# class > > cInstance = C() > c.NewProperty = "hop" #NewProperty Property is not defined at the > C# level. > > My questions: > > 1: is this the desired/expected behaviour? > 2: is this usable at C# level (I should test, I suppose, using > introspection ;-) > > --> I find it sometimes annoying not to know that I am defining a new > attribute, because such dynamicity is not expected at C# level (well at > python level). Hi Stan - Instance of managed class have Python semantics, meaning that you can set arbitrary attributes on the instance. If the attribute maps to a true managed attribute (field, property, etc.) then the value will be visible to managed code. *New* attributes are not visible to managed code -- there's really no way they could be, since most managed languages depend on the compile-time definition of a type and could rarely do anything useful with a dynamic attribute. The same holds true for Python sub-classes of managed types, which is the main way that extra (Python-only) attributes would be added: import CLR from CLR.System.Drawing import Point class MyPoint(Point): def __init__(self): self.Z = 0 In this case, managed code cannot see or use MyPoint.Z. It cannot see MyPoint at all, in fact -- an instance of MyPoint passed to a managed method will be seen by managed code as a Point instance. Subclassing is a case where technically we *could* be fancy and generate a managed subclass visible to the managed world if we worked hard enough. So far, I'm not convinced that its worth the work, given that the usefulness would be limited (again, because most managed languages work against compile-time metadata, a Python-generated managed subclass wouldn't really be useful for defining new types unless it could be persisted to an assembly for other managed code to build against). Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From bruce_dodson at hotmail.com Thu Jun 30 02:36:54 2005 From: bruce_dodson at hotmail.com (Bruce Dodson) Date: Wed, 29 Jun 2005 21:36:54 -0300 Subject: [Python.NET] running .net with standard 2.4.1 installation References: <429A86D1.4070407@r-e-d.co.nz> Message-ID: This is an old one but I'll follow up anyway... If you are using PythonWin for that test, you have to put a copy of Python.Runtime.dll in the same directory with pythonwin.exe, i.e. lib/site-packages/pythonwin. The same is probably true for other shells / host applications. For example if you wanted to use .NET with AVPython, you would probably need a copy of Python.Runtime.dll in the same folder with arcview.exe. I haven't tried putting Python.Runtime in the GAC, but that might do the trick too. Bruce "Guy Robinson" wrote in message news:429A86D1.4070407 at r-e-d.co.nz... > Hello, > > I've put the CLR and runtime dll's in my standard windows > 2.4.1 installation and > I'm getting the following(see below) crash and error > information. It appears the > runtime dll isn't being found. Yet they're both in the > python/dll directory. I > did have the binary pythonDotNet installed. But have > uninstalled it. > > Can anyone shed some light on what's going on? > > Regards, > > Guy > > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 > bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more > information. > >>> import CLR.System as System > > Unhandled Exception: System.IO.FileNotFoundException: File > or assembly name Pyth > on.Runtime, or one of its dependencies, was not found. > File name: "Python.Runtime" > at CLRModule.initCLR() > > === Pre-bind state information === > LOG: DisplayName = Python.Runtime, Version=1.0.0.0, > Culture=neutral, PublicKeyTo > ken=null > (Fully-specified) > LOG: Appbase = e:\python24\ > LOG: Initial PrivatePath = NULL > Calling assembly : (Unknown). > === > > LOG: Application configuration file does not exist. > LOG: Policy not being applied to reference at this time > (private, custom, partia > l, or location-based assembly bind). > LOG: Post-policy reference: Python.Runtime, > Version=1.0.0.0, Culture=neutral, Pu > blicKeyToken=null > LOG: Attempting download of new URL > file:///e:/python24/Python.Runtime.DLL. > LOG: Attempting download of new URL > file:///e:/python24/Python.Runtime/Python.Ru > ntime.DLL. > LOG: Attempting download of new URL > file:///e:/python24/Python.Runtime.EXE. > LOG: Attempting download of new URL > file:///e:/python24/Python.Runtime/Python.Ru > ntime.EXE. > > _________________________________________________ > Python.NET mailing list - > PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet >