Re: [IronPython] Problems with Iron Python Studio
What's wrong with good old SharpDevelop? If you grab a recent build from the build server it comes with IronPython 1.1, C#, VB.NET, Boo and F# support out of the box. I have been using this for all my .NET development needs. I'm not 100% certain if you can use the .NET debugger with IronPython, and I can't till I get to work tomorrow and get on a windows box, but I'm fairly certain it does. ~Tim On Tue, Jun 24, 2008 at 6:16 PM, Michael Foord [EMAIL PROTECTED] wrote: Michael Stephens wrote: It looks like the *only* way intellisense will pickup is if everything is in one file. A moderate workaround except for the lack of class navigator+function navigator You are likely to find the intellisense in Python IDEs like Wing and Komodo much better. They don't have Windows Forms or WPF designers though. You can still use Visual Studio / IronPython Studio to do your code generation - although I intensely dislike the code that IronPython Studio generates. Some Resolver One developers have an odd penchant for Vim as an IDE, which has intellisense of sorts... Michael Foord Michael Stephens Electrical Engineering Graduate Student University of Wyoming [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] or [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] On Tue, Jun 24, 2008 at 3:56 PM, Michael Foord [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Michael Stephens wrote: I should be able to just say dbg(test) should present intellisense at least for what dbg takes as an argument. import in Python is not the same as the C# using directive. If you do the following: import RT Then you can only access members of the RT module using: RT.attribute and you said that worked? If you want to be able to just type dbg(test) then you would need to do something like: from RT import dbg You can only use names you have specifically imported. I have no idea how good the IronPython Studio intellisense is though. Michael Foord Michael Stephens Electrical Engineering Graduate Student University of Wyoming [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] or [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] On Tue, Jun 24, 2008 at 3:49 PM, Curt Hagenlocher [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I don't understand from your description what you expect to see in Problem 2. On Tue, Jun 24, 2008 at 2:35 PM, Michael Stephens [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I have two instances where I can't get intellisense to work.Is it something I am doing or something wrong with Python Studio. I have attached a generated project. Problem 1: I can't access base class methods Problem 2: I can't access things declared in RT.py despite importing it.. The closest that that will work is import RT RT.dbg()// intellisense works! but i shouldnt need to call RT directly Any help would be appreciated. Michael Stephens Electrical Engineering Graduate Student University of Wyoming [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] or [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ___ Users mailing list Users@lists.ironpython.com mailto:Users@lists.ironpython.com mailto:Users@lists.ironpython.com mailto:Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com mailto:Users@lists.ironpython.com mailto:Users@lists.ironpython.com mailto:Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com mailto:Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com --http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/
Re: [IronPython] Exporting Python code as an assembly
I was testing out the code provided and when I tested it using the example I got the following error. Note: I'm using IronPython 2.0 Alpha (2.0.0.800) on .NET 2.0.50727.1433 C:\Documents and Settings\TJRiley\Desktop\ClrWrapperipy.exe MakeModule.py Xtest.py Traceback (most recent call last): File , line unknown, in _stub_##2 File C:\Documents and Settings\TJRiley\Desktop\ClrWrapper\Xtest.py, line 4, in Initialize File MakeModule.py, line 331, in Initialize File MakeModule.py, line 39, in GetExportedClasses IOError: Could not add reference to assembly xunit.dll On Feb 5, 2008 3:00 PM, Curt Hagenlocher [EMAIL PROTECTED] wrote: You can download my work-in-progress from http://hagenlocher.org/software/ClrWrapper.zip The source consists of the three files ClrBuilder.py, ClrWrapper.py and MakeModule.py. There are also two demo files: Xtest.py and WcfServer.py. The program can currently be run as follows: PS F:\IronPython-2.0A8 .\ipy.exe MakeModule.py Xtest.py This will produce a file called Xtest.dll. At this point, the application doesn't require any of the standard Python library files. It's only been tried with the Alpha 8 binaries -- and in fact, the hosting interfaces for IronPython still aren't entirely stable so there's no guarantee that the DLLs produced will work with Alpha 9. Xtest.py is a trivial application that implements a single xunit-compatible unit test PS F:\IronPython-2.0A8 .\xunit.console.exe Xtest.dll /noshadow . Total tests: 1, Failures: 0, Skipped: 0, Time: 0.275 seconds WcfServer.py theoretically implements a WCF server, though I haven't gotten as far as actually testing the output yet. (The generated code passes the eyeball compiler.) Code quality is unimpressive; your mileage may vary. And I've got to get back to my day job for a few hours now :). -- Curt Hagenlocher [EMAIL PROTECTED] ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Exporting Python code as an assembly
Well don't I feel like a moron. I should have spotted that. I apologize for posting before thinking. On Feb 5, 2008 4:29 PM, Curt Hagenlocher [EMAIL PROTECTED] wrote: On Feb 5, 2008 1:24 PM, Tim Riley [EMAIL PROTECTED] wrote: I was testing out the code provided and when I tested it using the example I got the following error. [snip] IOError: Could not add reference to assembly xunit.dll Sorry, you need xunit for that -- it's not part of IronPython. Xunit is a kind of next generation NUnit for unit testing, and I recommend it highly. You can find it at http://www.codeplex.com/xunit -- Curt Hagenlocher [EMAIL PROTECTED] ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] IronPython Studio
I just tried and am having the same problem. On Dec 11, 2007 2:16 PM, JoeSox [EMAIL PROTECTED] wrote: On 12/11/07, Fuzzyman [EMAIL PROTECTED] wrote: Hello all, My apologies if this has been announced on the list before - but I wasn't aware of it. http://www.codeplex.com/IronPythonStudio IronPython Studio is a free full IDE (Integrated Development Environment) for the Python programming language. It is based on the existing IronPython example that is included in the VS SDK. IronPython Studio is based on the Visual Studio 2008 Shell runtime (royalty free) and can be installed without requiring any version of Visual Studio. Very interesting... I just downloaded and installed the Visual Studio 2008 Shell (Isolated)redistributable package and the IronPython Studio setup does not detect that I have installed it. arrrg :( -- Later, JoeSox ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Hosting a python engine inside a windows form from IronPython code.
I am looking for some direction for running a GUI based IronPython console from IronPython code. I have found a sample of hosting IronPython in IronPython that Mr. Foord had created but it doesn't help me out with figuring out how to tie it to a RichTextBox. Has anyone done this and if so do they have any pointers they are willing to share? Thanks, Tim ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Hosting a python engine inside a windows form from IronPython code.
Thanks Joe. IronTextBox looks like what I'm looking for. However I can't use it as your source code indicates the code is released under the GPL which I don't think I can use from my MIT licensed project. After reading Michael's tutorial on embedding IronPython in IronPython I think I have a pretty good handle on what I need to do from my code. Thanks again. Tim On 10/10/07, JoeSox [EMAIL PROTECTED] wrote: On 10/10/07, Tim Riley [EMAIL PROTECTED] wrote: I am looking for some direction for running a GUI based IronPython console from IronPython code. I have found a sample of hosting IronPython in IronPython that Mr. Foord had created but it doesn't help me out with figuring out how to tie it to a RichTextBox. Has anyone done this and if so do they have any pointers they are willing to share? I am the author of IronTextBox http://www.codeproject.com/useritems/irontextbox.asp which is currently only for IP1 I have started an IP2 version looking at many different ways to due it but I have concluded to wait until IP2 is at least beta. Even then, I do wish IP2 was easier to integrate with textbox and richedit controls. But I really haven't invested much time into IronTextBox 2 so I still might be able to pull something off in the next few months. To be honest I really haven't been using IP2 until recently. Ideally, I would like as close as the Visual Studio IronPython Console as possible (color coding autocomplete etc.) but I was unable to find a hook at the time I was looking. But then the IronTextBox user would have to have Visual Studio installed and that really isn't ideal. -- Later, JoeSox ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Hosting: Delegates from Ironpython to C#
{ get { throw new NotSupportedException(Seek not supported); // can't seek } set { throw new NotSupportedException(Seek not supported); // can't seek } } public override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException(Reed not supported); // can't read } public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(Seek not supported); // can't seek } public override void SetLength(long value) { throw new NotSupportedException(Seek not supported); // can't seek } #endregion public override void Write(byte[] buffer, int offset, int count) { try { // Very bad hack: Ignore single newline char. This is because we expect the newline is following // previous content and we already placed a newline on that. AcEd.Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor; if (count == 1 buffer[offset] == '\n') return; StringBuilder sb = new StringBuilder(); while (count 0) { char ch = (char)buffer[offset]; if (ch == '\n') { ed.WriteMessage(sb.ToString() + \n); sb.Length = 0; // reset. } else if (ch != '\r') { sb.Append(ch); } offset++; count--; } if (sb.Length 0) ed.WriteMessage(sb.ToString() + \n); } catch (System.Exception e) { throw e; } } } } *CODE** On 8/30/07, Dino Viehland [EMAIL PROTECTED] wrote: I think you should be able to just pass a function object to PythonRegister and it should be converted into a delegate. For example: import clr clr.AddReference('PyAcadDotNet') from PyAcadDotNet import PyAcadCmd def foo(): print 'hello world' PyAcadCmd.PythonRegister('some command', foo, CommandFlags.Whatever) Does that not work? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Riley Sent: Wednesday, August 29, 2007 7:10 PM To: Discussion of IronPython Subject: [IronPython] Hosting: Delegates from Ironpython to C# I'm embedding IronPython in a C# dll that is hosted inside a program called AutoCAD. In order to register commands in AutoCAD from .NET I need to P/Invoke a C function inside a .dll. I can do this fairly easy from C# but I can't figure out the right way to call my C# wrapper from IronPython to have it register the command. I have perused the hosting docs for 1.1 and haven't been able to come up with a solution that works. Here is my C# code. I either want to call the PyRegCmds void or the PythonRegister void. Both of which expect a delegate.for example if I had a python function like: def test1: print This is a test. I can't figure out how to map test to the delegate required in the code below. Note: I can call this from C# fine. See :static public void test(). Can anyone give me any pointers? It would be greatly appreciated. code: using System ; using System.Runtime.InteropServices; using Autodesk.AutoCAD.Runtime ; using Autodesk.AutoCAD.EditorInput; namespace PyAcadDotNet { /// summary /// PyAcadCmd Class: /// Used to register commands on the AutoCAD command stack. /// /summary public class PyAcadCmd { public PyAcadCmd() { } public delegate void CmdDelegate(); /// summary /// RegPyAcadCmd: /// Registers a delegate (callback) with the AutoCAD command string /// on the command stack. /// /summary [DllImport(PyRegCmd.dll, CallingConvention=CallingConvention.Cdecl,CharSet = CharSet.Unicode, EntryPoint = ?RegPyCmd@@[EMAIL PROTECTED])] public static extern void RegPyCmd( string cmd_group, string cmd_name, Autodesk.AutoCAD.Runtime.CommandFlags cmd_flags, [MarshalAs(UnmanagedType.FunctionPtr)] PyAcadCmd.CmdDelegate cmd_delegate); public static void PythonRegister(string CommandName, CmdDelegate FuncPointer, CommandFlags flags) { RegPyCmd(_pycmds, CommandName, flags, FuncPointer); } //testing stuff public static void testcommand() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(\ncb1 delegate seems to work!\n); } [CommandMethod(regcmds)] static public void test() // This method can have any name { CmdDelegate cb1 = new CmdDelegate
Re: [IronPython] Hosting: Delegates from Ironpython to C#
of the call you'll need to do this anyway. Given that you're still in the call this shouldn't be an issue but you could set the environment variable COMPlus_MDA=1 to enable CLR Managed Debugging Assistants to see if you get any warnings about that firing. I don't really believe this could be happening but it would be consistent w/ the exception you're getting. Those are my 1st two guesses as to what could be going wrong, hopefully one of them will be helpful :). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Riley Sent: Thursday, August 30, 2007 8:59 AM To: Discussion of IronPython Subject: Re: [IronPython] Hosting: Delegates from Ironpython to C# Dino: I was trying something similar to what you had posted and was getting an error. I also just tried the code you gave me with a minor correction to fix the CommandFlags part and received the error below. If it helps I have also added the C# code use to call the python file below the error if that will help at all. *ERROR*** Command: pyfile System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at PyAcadDotNet.PyAcadCmd.RegPyCmd(String cmd_group, String cmd_name, CommandFlags cmd_flags, CmdDelegate cmd_delegate) at PyAcadDotNet.PyAcadCmd.PythonRegister(String CommandName, CmdDelegate FuncPointer, CommandFlags flags) in C:\Documents and Settings\TJRiley\My Documents\pyacaddotnet\registercommand.cs:line 65 at PythonRegister##20(Object , Object , Object ) at IronPython.Runtime.Calls.CallTarget3.Invoke(Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Calls.FastCallable3.Call(ICallerContext context, Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Calls.BuiltinFunction.Call(ICallerContext context, Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0, Object arg1, Object arg2) at C:\Documents and Settings\TJRiley\My Documents\pyacaddotnet\Samples\commandmethod_test.py##22(ModuleScope ) at IronPython.Hosting.CompiledCodeDelegate.Invoke(ModuleScope moduleScope) at IronPython.Hosting.CompiledCode.Run(ModuleScope moduleScope) at IronPython.Hosting.CompiledCode.Execute(EngineModule engineModule, IDictionary`2 locals) at IronPython.Hosting.CompiledCode.Execute() at PyAcadDotNet.AcadInterface.pythonfile() in C:\Documents and Settings\TJRiley\My Documents\pyacaddotnet\PyAcadDotNet.cs:line 98 *ERROR*** *CODE** using System; using System.Collections; using System.Windows.Forms; using System.IO; using System.Text; using System.Runtime.InteropServices; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.EditorInput; using AcEd = Autodesk.AutoCAD.EditorInput; using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; using IronPython.Hosting; namespace PyAcadDotNet { public class AcadInterface : IExtensionApplication { static internal AcEd.Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor; public delegate void TestDelegate(); public void Initialize() { ed.WriteMessage(\nPyAcad.NET Loaded Successfully); ed.WriteMessage(\ntype 'pyhelp' for commands); } public void Terminate() { this.Terminate(); } internal delegate void AddReference(object assembly); [CommandMethod(pyfile, CommandFlags.Session)] static public void pythonfile() { using (PythonEngine engine = new PythonEngine()) { using (AcadCommandLine myCommandLine = new AcadCommandLine()) { try { // Create a new instance of PythonEngine and set variables. engine.AddToPath(Environment.CurrentDirectory); // Send Stdout and Stderr to the AutoCAD command line. engine.SetStandardOutput(myCommandLine); engine.SetStandardError(myCommandLine); engine.Import(clr); PyAcadCmd regcmds = new PyAcadCmd(); engine.Globals.Add(regcmds, regcmds); //lets load some AutoCAD assemblies. AddReference adr = engine.CreateMethodAddReference(clr.AddReference(assembly)); adr(typeof(BlockTableRecord).Assembly); adr(typeof(Editor).Assembly); // Display an OpenFileDialog and run the script. OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = Python files (*.py)|*.py|All files (*.*)|*.*; ofd.ShowDialog(); // Run the file selected by the open file dialog box. //engine.ExecuteFile(ofd.FileName); CompiledCode cc = engine.CompileFile(ofd.FileName
Re: [IronPython] Hosting: Delegates from Ironpython to C#
Dino: I revised the code to what you suggested and still no luck. Is there any way I can set the environment variable other than via the command prompt? My application is hosted inside another application and I can't set the variable from there. Tim On 8/30/07, Dino Viehland [EMAIL PROTECTED] wrote: Setting the env var at runtime won't help, you'll want to set it at a command prompt and start your app from the command prompt. One other tweak: public static void PythonRegister(string CommandName, CmdDelegate FuncPointer, CommandFlags flags) { PythonDelegateWrapper pdw = new PythonDelegateWrapper(FuncPointer)); RegPyCmd(_pycmds, CommandName, flags, new CmdDelegate(pdw.Invoke); GC.KeepAlive(pdw); } Which will ensure it's not a delegate getting collected issue. If that doesn't work then we'll need to go into unmanaged debugging territory w/ windbg/cdb/ntsd :). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Riley Sent: Thursday, August 30, 2007 11:55 AM To: Discussion of IronPython Subject: Re: [IronPython] Hosting: Delegates from Ironpython to C# Dino: I tried using the PythonDelegateWrapper you posted below with the same results. To make things easier I tried moving all my testing into a single C# file and have it run the code from C# instead of a compiling a python file. Below is the code. When I execute regtest in AutoCAD it fatal errors on me. I also added System.Environment.SetEnvironmentVariable(COMPlus_MDA, 1); to the initialize of my code but it doesn't do anything for me. Any other ideas? code* using System ; using System.Runtime.InteropServices; using Autodesk.AutoCAD.Runtime ; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using IronPython.Hosting; namespace PyAcadDotNet { /// summary /// PyAcadCmd Class: /// Used to register commands on the AutoCAD command stack. /// /summary public class PyAcadCmd { public PyAcadCmd() { } public delegate void CmdDelegate(); internal delegate void AddReference(object assembly); /// summary /// RegPyAcadCmd: /// Registers a delegate (callback) with the AutoCAD command string /// on the command stack. /// /summary [DllImport(PyRegCmd.dll, CallingConvention=CallingConvention.Cdecl,CharSet = CharSet.Unicode, EntryPoint = ?RegPyCmd@@[EMAIL PROTECTED])] public static extern void RegPyCmd( string cmd_group, string cmd_name, Autodesk.AutoCAD.Runtime.CommandFlags cmd_flags, [MarshalAs(UnmanagedType.FunctionPtr)] CmdDelegate cmd_delegate); public static void PythonRegister(string CommandName, CmdDelegate FuncPointer, CommandFlags flags) { RegPyCmd(_pycmds, CommandName, flags, new CmdDelegate(new PythonDelegateWrapper(FuncPointer).Invoke)); } //testing stuff public static void testcommand() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(\ncb1 delegate seems to work!\n); } [CommandMethod(regcmds)] static public void test() // This method can have any name { CmdDelegate cb1 = new CmdDelegate(PyAcadCmd.testcommand); PythonRegister(testcommand, cb1, CommandFlags.Session); } [CommandMethod(regtest, CommandFlags.Session)] static public void regtest() { PythonEngine engine = new PythonEngine(); engine.Import(clr); AddReference adr = engine.CreateMethodAddReference(clr.AddReference(assembly)); adr(typeof(BlockTableRecord).Assembly); adr(typeof(Editor).Assembly); CompiledCode cc = engine.Compile( @ import Autodesk.AutoCAD.Runtime import clr clr.AddReference('PyAcadDotNet') from PyAcadDotNet import PyAcadCmd def foo(): print 'hello world' PyAcadCmd.PythonRegister('pythontester', foo, Autodesk.AutoCAD.Runtime.CommandFlags.Session)); cc.Execute(); } } class PythonDelegateWrapper { private PyAcadCmd.CmdDelegate cmdDelegate; public PythonDelegateWrapper(PyAcadCmd.CmdDelegate dlg) { cmdDelegate = dlg; } public void Invoke() { cmdDelegate(); } } } code** On 8/30/07, Dino Viehland [EMAIL PROTECTED] wrote: Well at this point
[IronPython] IronPython Attribute Workaround
I know that IronPython doesn't support attributes but does anyone know of a workaround that will allow IP code to use them? ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] IronPython Attribute Workaround
I am messing around with some code that will allow me to use IronPython to automate AutoCAD software via it's .NET API. I already have hacked up some ugly C# code that creates an instance of a PythonEngine and executes a python file a select via an open file dialog box. All works well with this. The next step I'd like to take is to attempt to create a mechanism for registering AutoCAD commands via python code (so I don't have to select a file every time I want to run it. AutoCAD's .NET API allows you to register a command that is callable from the AutoCAD via a CommandMethod attribute[1]. Since IP doesn't support attributes I'd like to develop some sort of decorator that would clone the functionality of the CommandMethod attribute. So I could execute python code like: @commandmethod(test) def tester: print test worked and it would register the test command so I could call it from the command line. [1] As an example: http://through-the-interface.typepad.com/through_the_interface/2007/07/updating-a-spec.html Tim On 7/23/07, Michael Foord [EMAIL PROTECTED] wrote: Tim Riley wrote: Michael: Thanks for the reply. However when reading it my eyes glazed over. Is there any way you could provide a simple man like myself with some example code for me to peruse? What do you want to achieve? Write the IronPython code you would like - and I will try and provide a C# stub that you can subclass. (You will need a C# compiler - Visual Studio Express C# is probably the most straightforward if you are using Windows.) Michael Foord http://www.voidspace.org.uk/ironpython/index.shtml Tim On 7/23/07, Michael Foord [EMAIL PROTECTED] wrote: Tim Riley wrote: I know that IronPython doesn't support attributes but does anyone know of a workaround that will allow IP code to use them? The IronPython team are strangely quiet every time someone asks this... ;-) A lot of people would like an answer to this question. Currently the only way is to use stub C# classes. Michael Foord http://www.voidspace.org.uk/ironpython/index.shtml ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [Users] [IronPython] IronPython Attribute Workaround
Michael: Earlier today I was doing some digging using Lutz Roeder's .NET Reflector and it seems that the CommandMethod attribute registers the command using the acmgd.Autodesk.AutoCAD.Runtime.ICommandLineCallable interface. As I can tap into any other aspect of AutoCAD's .NET api via ironpython I'm going to assume that I can somehow tap into this and register a command. The only problem is I don't have a clue how...yet. If you want to take a look at what C# code I have so far you can find it @ http://pyacaddotnet.googlecode.com/svn/trunk/PyAcadDotNet.cs Also I have some (lousy) samples that I use for testing IronPython in AutoCAD. You can find them here: http://pyacaddotnet.googlecode.com/svn/trunk/Samples/ Tim On 7/23/07, Michael Foord [EMAIL PROTECTED] wrote: I'm pretty sure that it is impossible to dynamically generate classes decorated with attributes at runtime using 'pure C#'. The two alternatives are either to use the Reflection.Emit API - which is probably the best way but requires more digging than I have time for at this point in time. Another alternative is to dynamically generate C# and compile to in memory assemblies. This is less memory efficient because it requires an assembly and type object for every command you wish to add. It is a lot faster than you might expect. Attached are two files. One is 'generate.py'. It has a function called 'Generate' which compiles C# using the CodeDom API with the CSharpCodeProvider. As an example I have provided another file - DllImport.py. This uses Generate to compile the C# from my screenshot example : http://www.voidspace.org.uk/ironpython/winforms/part10.shtml It works fine. :-) The specific call is : assembly = Generate(unmanaged_code, 'UnamangedCode', inMemory=True) clr.AddReference(assembly) from UnmanagedCode import User32, GDI32 (You can also use it to save assemblies to disk.) For your use you will need to pass in a list of references (absolute file paths) to the AutoCAD DLLs that your C# code is dependent on. I think you need to generate C# code that looks something like: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; namespace AutoCADStuff { public class AutoCADStuffBase { [CommandMethod(myname)] public void method { _method(); } public virtual void _method { return null; } } In IronPython you can call 'Generate', then import and subclass AutoCADStuffBase and override '_method': class AutoCADStuff(AutoCADStuffBase): def _method(self): some code ... I have used this approach with Silverlight assemblies for creating classes with methods marked with attributes. I hope this helps. Please no one post this code as is - I'll write up and post an article shortly. :-) Michael Foord Michael Foord wrote: Tim Riley wrote: [snip..] AutoCAD's .NET API allows you to register a command that is callable from the AutoCAD via a CommandMethod attribute[1]. Since IP doesn't support attributes I'd like to develop some sort of decorator that would clone the functionality of the CommandMethod attribute. So I could execute python code like: @commandmethod(test) def tester: print test worked and it would register the test command so I could call it from the command line. Right - so you want to dynamically create methods (or functions) with attributes. The attribute takes the name that the command will be exposed with. I wonder if AutoCAD even supports these being dynamically created? If it does I wonder if we can do it by creating an inner class in C#. The method marked with the attribute would call down to another method (marked as virtual) that we can override from IronPython. I'm not exactly sure of the C# syntax/semantics for inner classes - (a class factory) - so I'll have to do some digging. (i.e. will it allow us to set the argument to the attribute at runtime rather than compile time and can we return classes or only instances.) AFAIK, attributes are normally bound at compile time rather than runtime, so using C# to create classes in this way may not work. The proper way (*sigh*) is to use the Reflection.Emit API to add attributes. I've experimented Reflection.Emit - but never got as far as adding attributes dynamically. (You need to 'program in bytecode' using this API - which isn't too bad but has a bit of a learning curve associated.) A *third* approach is to dynamically generate C# and compile to in memory assemblies (using the CodeDOM API if I remember correctly). That turns out to be surprisingly easy. Michael Foord http://www.voidspace.org.uk/ironpython/index.shtml [1] As an example: http://through-the-interface.typepad.com/through_the_interface/2007/07/updating-a-spec.html Tim On 7/23/07
Re: [IronPython] cherrypy
No, copy the folder itself. Python will look in the directory you're running code from first for libraries. If it finds a folder with __init__.py in it then it will import it as a library. On 12/28/06, J. Merrill [EMAIL PROTECTED] wrote: Do you mean to copy the _contents_ of the cherrypy folder? So if trying to run from the directory where setup.py is found, before that do copy cherrypy\*.* . ? At 03:46 PM 12/27/2006, Tim Riley wrote Copy the cherrypy folder that is in the same folder containing setup.pydirectly into the directory you're trying to run your code from. You don't need to put it into site packages. On 12/27/06, *Ivan Porto Carrero* [EMAIL PROTECTED] wrote: I'm sorry but if I try that it will always come up with the message that it can't find distutils.core I've set the environment variable and if i try to get _fileobject from the sockets module it works But when I do ipy setup.py install for cherrypy it tells me the distutils module can't be found. [snip] J. Merrill / Analytical Software Corp ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] cherrypy
Copy the cherrypy folder that is in the same folder containing setup.pydirectly into the directory you're trying to run your code from. You don't need to put it into site packages. On 12/27/06, Ivan Porto Carrero [EMAIL PROTECTED] wrote: I'm sorry but if I try that it will always come up with the message that it can't find distutils.core I've set the environment variable and if i try to get _fileobject from the sockets module it works But when I do ipy setup.py install for cherrypy it tells me the distutils module can't be found. I have little or no experience with python. But I prefer it over ruby so if I can get it to run pylons, turbogears or django it would be great. I need ironpython because I have to integrate with existing asp.net applications that have stored hashes in the database. I know webdevelopment and I know mvc frameworks. So that would be a good way to get me started with python without losing too much productivity Thanks already for your help. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sanghyeon Seo Sent: Thursday, 28 December 2006 3:46 a.m. To: Discussion of IronPython Subject: Re: [IronPython] cherrypy 2006/12/27, Ivan Porto Carrero [EMAIL PROTECTED]: I'd like to use cherrypy with ironpython. But I'm not sure if that is possible. If it is where can i find something on how to get it to install ? It works fine with IPCE. Download it here: http://fepy.sourceforge.net/ You need to enable encoding and network option. http://fepy.sourceforge.net/doc/fepy-options.html#available-options -- Seo Sanghyeon ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] New Windows Forms Tutorial Entry
Michael: Very good stuff. Thank you for taking the time to provide this to the community. ~Tim On 12/17/06, Michael Foord [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: {ran_emo} In celebration of the new IronPython section I've added a new entry to the `Windows Forms Tutorial Series /ironpython/winforms/index.shtml`_. This is entry number eleven : * `Towards a Richer GUI: The TabControl, Splitter the PictureBox /ironpython/winforms/part11.shtml`_ It uses a few new controls to create a *slightly* more complex GUI than we've seen before in this series. .. image:: /ironpython/winforms/images/verticalSplitter.jpg :height: 369 :width: 517 :alt: A Vertical Splitter :align: center :class: image :target: /ironpython/winforms/part11.shtml Again, the full links are : http://www.voidspace.org.uk/ironpython/winforms/index.shtml http://www.voidspace.org.uk/ironpython/winforms/part11.shtml http://www.voidspace.org.uk//ironpython/winforms/images/verticalSplitter.jpg I'm not sure if the example here will work with Mono as it uses stuff from Windows Forms 2. If anyone could test and preferably remove / rewrite the parts that don't work (and provide screenshots) I'd be happy to include a Mono section in the entry. Michael http://www.voidspace.org.uk/index2.shtml ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.22/590 - Release Date: 16/12/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.22/590 - Release Date: 16/12/2006 ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] one click
You don't need to package the IronPython distribution if you compile your code to a stand alone executable using Pyc from the samples. See: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPythontitle=Samples On 11/24/06, Bill64bits [EMAIL PROTECTED] wrote: Suppose you want to deploy a Wndow Forms app written in IronPython thoughout an organization via a web page using one-click deployment. Is it easy to install the IP distribution on each pc with that same click ? . ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Web.py and Ironpython
Has anyone successfully got web.py to work with IronPython? I'd be very interested to hear about it if anyone has. ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] IronPython Samples
I know you can download some neat samples from IronPython's codeplex page but I think it would be nice if there were a place where end users could place snippets of code and example programs for others to use. I was thinking of maybe something like http://www.infogami.com where multiple people could add samples. Any thoughts?Regards,Tim Riley ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] New - PythonEngine documentation
Very useful. Thank you for pointing that out as I hadn't noticed.TimOn 9/8/06, Shri Borde [EMAIL PROTECTED] wrote: In case you hadn't noticed, there is a new IronPythonApiReference.chm in the Doc folder in the zip 1.0 RTM zip files, both bin and src. This should help answer many of the questions which come up about the specifics of the hosting APIs. Thanks, Shri PS: I thought I had sent this email earlier but didn't see it on the mailing list. ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] PythonEngine.RunFile
Thank you both. I will give that a shot.On 8/10/06, Shri Borde [EMAIL PROTECTED] wrote: __name___ == __main__: is a convention enforced by ipy.exe. The PythonEngine itself does not directly support this concept. However, you can achieve that result (just like ipy.exe does) by using code like this: PythonEngine engine = new PythonEngine(); EngineModule module = engine.CreateModule("__main__", false); engine.ExecuteFile(filename, module); Do you want to help develop Dynamic languages on CLR? ( http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Martin Maly Sent: Thursday, August 10, 2006 3:06 PM To: Discussion of IronPython Subject: Re: [IronPython] PythonEngine.RunFile You can try the PythonEngine.CreateOptimizedModule which you can also pass a name your module should get. Let us know if that doesn't meet your needs. Martin From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 2:17 PM To: Discussion of IronPython Subject: Re: [IronPython] PythonEngine.RunFile I've tested that and I don't think it works with: if __name___ == __main__: in the python script. Regards, Tim Riley On 8/10/06, Martin Maly [EMAIL PROTECTED] wrote: Think PythonEngine.ExecuteFile may work for you. From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 1:01 PM To: Discussion of IronPython Subject: [IronPython] PythonEngine.RunFile In IP version 0.9 there was a PythonEngine.RunFile() method, this seems to be gone in 1.0.6. Is there a replacement? ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Embedding Question
If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible?Regards,Tim Riley ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedding Question
What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, acmgd.dll and acdbmgd.dll. These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD. For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script. So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project.Note: I'm fine with the import statements.On 8/10/06, Dino Viehland [EMAIL PROTECTED] wrote: Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module. Were you also trying to avoid the import statements? From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:02 AM To: Discussion of IronPython Subject: [IronPython] Embedding Question If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedding Question
That's exactly what I needed. Thank you Dino.On 8/10/06, Dino Viehland [EMAIL PROTECTED] wrote: You can get the assembly object from an AutoCAD type: typeof(Foo).Assembly. From there you just need to have one helper which will register this in the engine, so you could do: delegate void AddReference(object assembly); AddReference adr = engine.CreateMethodAddReference("clr.AddReference(assembly)"); adr.AddReference(typeof(SomeAutoCadType).Assembly); and then from there you should be able to import any of the AutoCAD namespaces from any of your modules. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:40 AM To: Discussion of IronPython Subject: Re: [IronPython] Embedding Question What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, acmgd.dll and acdbmgd.dll. These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD. For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script. So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project. Note: I'm fine with the import statements. On 8/10/06, Dino Viehland [EMAIL PROTECTED] wrote: Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module. Were you also trying to avoid the import statements? From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:02 AM To: Discussion of IronPython Subject: [IronPython] Embedding Question If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] PythonEngine.RunFile
In IP version 0.9 there was a PythonEngine.RunFile() method, this seems to be gone in 1.0.6. Is there a replacement? ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedding Question
Thanks Dino. I had figured that out.On 8/10/06, Dino Viehland [EMAIL PROTECTED] wrote: Cool, looks like I was only close though J You may have already imported clr into the default module, but just for the record for those who haven't you'll need an import clr there. I just realized I forgot it the 1st time, and I had a redundant "AddReference" in the delegate call. I'm assuming you just fixed all that up, but just in case anyone else needs to do something like this, here's the correct code: delegate void AddReference(object assembly); AddReference adr = engine.CreateMethodAddReference(import clr\nclr.AddReference(assembly)); adr(typeof(SomeAutoCadType).Assembly); From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 12:10 PM To: Discussion of IronPython Subject: Re: [IronPython] Embedding Question That's exactly what I needed. Thank you Dino. On 8/10/06, Dino Viehland [EMAIL PROTECTED] wrote: You can get the assembly object from an AutoCAD type: typeof(Foo).Assembly. From there you just need to have one helper which will register this in the engine, so you could do: delegate void AddReference(object assembly); AddReference adr = engine.CreateMethodAddReference(clr.AddReference(assembly)); adr.AddReference(typeof(SomeAutoCadType).Assembly); and then from there you should be able to import any of the AutoCAD namespaces from any of your modules. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:40 AM To: Discussion of IronPython Subject: Re: [IronPython] Embedding Question What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, acmgd.dll and acdbmgd.dll. These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD. For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script. So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project. Note: I'm fine with the import statements. On 8/10/06, Dino Viehland [EMAIL PROTECTED] wrote: Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module. Were you also trying to avoid the import statements? From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:02 AM To: Discussion of IronPython Subject: [IronPython] Embedding Question If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] NET Attributes.
Thanks for all the info. I was looking into using IP with AutoCAD and .NET attributes are required.tjrOn 7/26/06, Michael Foord [EMAIL PROTECTED] wrote:Martin Maly wrote: Unfortunately, no. Adding .NET attributes on Python classes in IronPython is not possible. Somewhat similar Pythonic thing is function and method decorators: @command("MyCommand", CommandFlags.Modal) def RunMyCommand(): …. However, this will not interoperate well with .NET since .NET is not aware of the decorator mechanism. For more information, you can check out: http://docs.python.org/whatsnew/node6.html There is another option to use function doc strings, but that would be more complicated to use and I'd probably use it as one of the last resorts. However if you need to mark a class as serializable (or use any other.NET attribute), you just can't do it from IronPython at the moment. :-(Fuzzyman http://www.voidspace.org.uk/python/index.shtml Martin *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] *On Behalf Of *Tim Riley *Sent:* Wednesday, July 26, 2006 10:17 AM *To:* Discussion of IronPython *Subject:* [IronPython] NET Attributes. Is it possible to use .NET attributes in IronPython? For example I have C# code that looks like: [CommandMethod(MyCommand, CommandFlags.Modal)] public static void RunMyCommand() { 'code here } Can I do something similiar in IP? I'll take anything. ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] NET Attributes.
Is it possible to use .NET attributes in IronPython? For example I have C# code that looks like:[CommandMethod(MyCommand, CommandFlags.Modal)]public static void RunMyCommand(){ 'code here }Can I do something similiar in IP? I'll take anything. ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Strange Embedding Questions
I have an application that I am working on which basically will provide IronPython as a scripting language for AutoCAD. I have a command now that will allow me to select an external python file and run it in AutoCAD, manipulating objects and such. This works fine for testing purposes but in order to release this as a tool that people will use for production purposes I need to develop some sort of loading mechanism that will allow me to do something like load 12 python files at once and call them as needed instead of having an Open File Dialog box pop up every time a user wants to run a script. My next issue which is somewhat coupled with the first. In AutoCAD I would develop a custom command in C# using attributes like this: [CommandMethod(pyfile, CommandFlags.Transparent)] public void pythonfile() { // Create a new instance of PythonEngine and set variables. PythonEngine engine = new PythonEngine(); engine.AddToPath(Environment.CurrentDirectory ); // Send Stdout and Stderr to the AutoCAD command line. engine.SetStdout(new AcadCommandLine()); engine.SetVariable(null, null);// Display an OpenFileDialog and run the script. OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = Python files (*.py)|*.py|All files (*.*)|*.* ; ofd.ShowDialog(); // Run the file selected by the open file dialog box. engine.RunFile(ofd.FileName); }Basically I need to come up with some method of defining that CommandMethod Attribute from python file. I'm not necessarily concerned how ugly of a hack it will be but I need a method of defining custom commands from an external file. Anyone have any thoughts/ideas on this. I'm not necessarily looking for a full code solution, however some pointer would be extremely helpful.Thanks for reading,Tim Riley ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Newbie mono question (setting up lib path)
This works for me using Mono 1.1.13 and IronPython 1.0.2190 on Windows XP.IronPython 1.0.2190 (Beta) on .NET 2.0.50727.42Copyright (c) Microsoft Corporation. All rights reserved. import sys sys.path.append('c:\Python24\Lib') import string dir(string)['ImportError', 'KeyError', 'Template', 'True', 'TypeError', 'ValueError', '_TemplateMetaclass', '__builtins__', '__dict__', '__doc__', '__file__', '__name__', '_float', '_idmap', '_idmapL', '_int', ' _long', '_multimap', '_re', 'ascii_letters', 'ascii_lowercase', 'ascii_uppercase', 'atof', 'atof_error', 'atoi', 'atoi_error', 'atol', 'atol_error', 'basestring', 'capitalize', 'capwords', 'center', 'chr', 'count', 'digits', 'expandtabs', 'find', 'float', 'hexdigits', 'index', 'index_error', 'int', 'isinstance', 'join', 'joinfields', 'len', 'letters', 'ljust', 'long', 'lower', 'lowercase', 'lstrip', 'maketrans', 'map', 'octdigits', 'ord', 'printable', 'punctuation', 'range', 'replace', 'repr', 'rfind', 'rindex', 'rjust', 'rsplit', 'rstrip', 'split', 'splitfields', 'str', 'strip', 'super', 'swa pcase', 'translate', 'type', 'upper', 'uppercase', 'whitespace', 'xrange', 'zfill']On 1/16/06, m h [EMAIL PROTECTED] wrote:h, string.py is in \\tmp\\ipython\\IronPython- 1.0-Beta1\\Libwhich is in my path...mharrison[1080] mono IronPythonConsole.exeIronPython 1.0.2190 (Beta) on .NET 2.0.50727.42Copyright (c) Microsoft Corporation. All rights reserved. import string Traceback (most recent call last):ImportError: No module named string import sys sys.path['\\tmp\\ipython\\IronPython-1.0-Beta1','\\tmp\\ipython\\IronPython-1.0-Beta1\\Lib'] On 1/14/06, Martin Maly [EMAIL PROTECTED] wrote: this sounds like IronPython couldn't find the string module. try: import sys sys.path and make sure it found its way there correctly. If in doubt, try absolute paths. Hopefully this helps Martin From: [EMAIL PROTECTED] On Behalf Of m h Sent: Friday, January 13, 2006 6:00 PM To: users@lists.ironpython.com Subject: [IronPython] Newbie mono question (setting up lib path) Folks, I'm new to IronPython (and Mono!). Following what I read in Jim's recent email, I tried copying my python2.3 lib directory into the Lib directory and added Lib to the sys.path in Lib/site.py.Then I tried to import string but it failed.Any hints? mharrison[1080] mono IronPythonConsole.exe IronPython 1.0.2190 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. import string Traceback (most recent call last): ImportError: No module named string mharrison[1045] mono --version Mono JIT compiler version 1.1.13, (C) 2002-2005 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC:Included Boehm (with typed GC) SIGSEGV: normal thanks matt ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Problems with Mono and Tab Completion.
Runtime: Mono-1.1.13Version: IronPython 1.0.2190When executing IronPython from the following batch file I get some weird behavior in IronPythonConsole.exe. It seems that as I type in the console it sends two of each character. This behavior only occurs when I pass the -X:TabCompletion parameter. Has anyone else experienced this type of behavior? If so is there a workaround?Regards,Tim RileyContents of mono-ipc.bat**@echo offC:\Program Files\Mono- 1.1.13\bin\mono.exe C:\IronPython\IronPythonConsole.exe -X:TabCompletion@echo on** ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Bitwise boolean operators and Forms
I don't understand. Why would you use an or statement when assigning a dockstyle?~TimOn 12/28/05, jeff sacksteder [EMAIL PROTECTED] wrote:The code in this snippet fails, claiming the bitwise operator '|' is unsupported for for DockStyles. Is this an unimplemented item, bug, or misunderstanding on my part? import sys sys.LoadAssemblyByName('System.Windows.Forms') from System.Windows.Forms import * my_control = RichTextBox() my_control.Dock = DockStyle.Right | DockStyle.Left my_control.AutoSize = True my_form = Form() my_form.Controls.Add(my_control) my_form.Show() Application.Run(my_form) ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] IronPython on mac os X (newbie problems)
I may be wrong but I was under the impression that the more recent versions of IronPython utilized portions of the .NET 2 framework that have yet to be implemented in mono.Regards,Tim Riley On 12/19/05, Anand Pillai [EMAIL PROTECTED] wrote: Incidentally, I got the same error with IronPython 0.9.6 and thelatest version of monoon a FC3 (Fedora Core 3) box.I had installed IronPython to /opt/IronPython. Initially IronPythonwas running fine. Then I wanted to try out the tutorials and so I did the following:alias 'iron'='mono /opt/IronPython/bin/IronPythonConsole.exe'Then I tried to run the examples using 'iron sample.py'. At thatpoint it started giving this error.I dont have the traceback since this happened in the office and I am posting from home. I can send it later if reqd.Thanks-AnandOn 12/17/05, S V N Vishwanathan [EMAIL PROTECTED] wrote: Hi! I am a newbie to IronPython. Maybe I am missing something here ... I installed the latest version of Mono on my Mac OS X (10.4) box and downloaded IronPython and tried % mono IronPythonConsole.exe ** (IronPythonConsole.exe:653): WARNING **: implement me 0x00 ** ERROR **: file class.c: line 3030 (mono_class_from_mono_type): should not be reached aborting... zsh: abortmono IronPythonConsole.exe The relevant version of Mono is: % mono --version Mono JIT compiler version 1.1.10, (C) 2002-2005 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC:Included Boehm (with typed GC) SIGSEGV: normal and the OS is % uname -a Darwin Ambica.local 8.3.0 Darwin Kernel Version 8.3.0: Mon Oct3 20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC Power Macintosh powerpc What am I doing wrong? Please do not hesitate to ask me if you need any further information. vishy ps: I am not subscribed to the list. So Pls cc me on the responses. ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com --Anand B Pillai,Staff Engineer (Development),SpikeSource India Pvt Ltd,Koramangala 3rd Block,Bangalore, India.http://www.spikesource.com Blog: http://randombytes.blogspot.com___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] IronPython on mac os X (newbie problems)
Actually, now I just tested it will mono-1.1.12 on win32 and it appears to be working. Possibly you need to upgrade your version of mono.C:\IronPython\binmono --versionMono JIT compiler version 1.1.12, (C) 2002-2005 Novell, Inc and Contributors. ww w.mono-project.com TLS: normal GC: Included Boehm (with typed GC) SIGSEGV : normalC:\IronPython\binmono IronPythonConsole.exe IronPython 0.9.6 on .NET 2.0.50727.42Copyright (c) Microsoft Corporation. All rights reserved.On 12/20/05, Tim Riley [EMAIL PROTECTED] wrote:I may be wrong but I was under the impression that the more recent versions of IronPython utilized portions of the .NET 2 framework that have yet to be implemented in mono. Regards,Tim Riley On 12/19/05, Anand Pillai [EMAIL PROTECTED] wrote: Incidentally, I got the same error with IronPython 0.9.6 and thelatest version of monoon a FC3 (Fedora Core 3) box.I had installed IronPython to /opt/IronPython. Initially IronPythonwas running fine. Then I wanted to try out the tutorials and so I did the following:alias 'iron'='mono /opt/IronPython/bin/IronPythonConsole.exe'Then I tried to run the examples using 'iron sample.py'. At thatpoint it started giving this error.I dont have the traceback since this happened in the office and I am posting from home. I can send it later if reqd.Thanks-AnandOn 12/17/05, S V N Vishwanathan [EMAIL PROTECTED] wrote: Hi! I am a newbie to IronPython. Maybe I am missing something here ... I installed the latest version of Mono on my Mac OS X (10.4) box and downloaded IronPython and tried % mono IronPythonConsole.exe ** (IronPythonConsole.exe:653): WARNING **: implement me 0x00 ** ERROR **: file class.c: line 3030 (mono_class_from_mono_type): should not be reached aborting... zsh: abortmono IronPythonConsole.exe The relevant version of Mono is: % mono --version Mono JIT compiler version 1.1.10, (C) 2002-2005 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC:Included Boehm (with typed GC) SIGSEGV: normal and the OS is % uname -a Darwin Ambica.local 8.3.0 Darwin Kernel Version 8.3.0: Mon Oct3 20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC Power Macintosh powerpc What am I doing wrong? Please do not hesitate to ask me if you need any further information. vishy ps: I am not subscribed to the list. So Pls cc me on the responses. ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com --Anand B Pillai,Staff Engineer (Development),SpikeSource India Pvt Ltd,Koramangala 3rd Block,Bangalore, India. http://www.spikesource.com Blog: http://randombytes.blogspot.com___ users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Word Automation
snip mApp.Documents.Open(c:\tmp\Doc1.doc) System.Runtime.InteropServices.COMException: The document name or path is not va lid. Try one or more of the following: * Check the path to make sure it was typed correctly. (c:mp\Doc1.doc)click Open. Search for the file using this dialog box. at input_6.Run(Frame frame) /snip You need to escape the backslashes. Should have been c:\\tmp\\Doc1.doc. Also \t translate to a tab which is shown in the error. Tim Riley On 6/19/05, kbond [EMAIL PROTECTED] wrote: Hello, Congratulation, for this new release correcting some bugs around the PIA ComObject Operations. I spent the last hours playing around with this great feature of ironpython and I would like to share with you a couple of things. Some are working fine some seems strange to me but it might be because I am missing something and some that are not working. Scenario 1 IronPython 0.7.6 on .NET 2.0.50215.44 Copyright (c) Microsoft Corporation. All rights reserved. import sys sys.LoadAssemblyByName(Microsoft.Office.Interop.Word) import Microsoft.Office.Interop.Word as wordApp mApp= wordApp.ApplicationClass() mApp.visible False mApp.visible = True mApp.Documents.Open(c:\tmp\Doc1.doc) System.Runtime.InteropServices.COMException: The document name or path is not va lid. Try one or more of the following: * Check the path to make sure it was typed correctly. (c:mp\Doc1.doc)click Open. Search for the file using this dialog box. at input_6.Run(Frame frame) ### I do not undertstand why this is not working however a slightly modified statement is working well## doc1 = mApp.Documents.Open(r'c:\tmp\Doc1.doc') doc1.Save() doc1.Close() Scenario 2 doc1 = mApp.Documents.Open(r'c:\tmp\Doc1.doc') doc2 = mApp.Documents.Add() doc2.SaveAs(rc:\tmp\Doc2.doc) for i in mApp.Documents: ... print i.Name ... System.Runtime.InteropServices.COMException: Unknown name. (Exception from HRESU LT: 0x80020006 (DISP_E_UNKNOWNNAME)) at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Bi nder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers , CultureInfo culture, String[] namedParams) at input_24.Run(Frame frame) ## I do not understand why I cannot iterate in the collection of Documents## ## May be this is not supposed to work but it would be amazingly efficient mApp.Documents(Doc1.doc).Activate() System.Runtime.InteropServices.COMException: Unknown name. (Exception from HRESU LT: 0x80020006 (DISP_E_UNKNOWNNAME)) at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Bi nder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers , CultureInfo culture, String[] namedParams) at input_29.Run(Frame frame) # Another problem when working with a collection of documents # # I cannot select a given document using its Name # Scenario 3 # I would like to translate the following vb statement in python## #vb Documents.Open FileName:=C:\Files\Doc.doc, ReadOnly:=True doc3 = mApp.Documents.Open(FileName='c:\tmp\Doc1.doc', ReadOnly= True) System.Exception: this object is not callable with keyword parameters at input_32.Run(Frame frame) Obviously, my guess was wrong but I do not have any idea on how to do such thing any advise would be more than welcome## Could you please help me to positionned win32com and IronPython? Would it be possible to do the same things with IronPython than with win32com? Thank you very much for your answers, I hope that will help you . Regards ___ users-ironpython.com mailing list users-ironpython.com@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users-ironpython.com mailing list users-ironpython.com@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com