![]() |
Desktop Development »
Miscellaneous »
General
Intermediate
License: The Code Project Open License (CPOL)
IronTextBox - a TextBox and UserControl based console that may be used with IronPython.By JoeSoxA Short Introduction to IronPython. IronTextBox v1.4.1.0b |
C#, Windows, .NET, Visual-Studio, Dev
|
||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Microsoft's IronPython 1.0 (or try IronPython's main website for the latest release) is a release of the Python programming language for the .NET platform. Below are some of the most important of IronPython's 1.0 namespaces and counting:
namespace IronPython.Compiler; namespace IronPython.Compiler.Ast; namespace IronPython.Hosting; namespace IronPython.Modules; namespace IronPython.Runtime; namespace IronPython.Runtime.Exceptions; namespace IronPython.Runtime.Calls; namespace IronPython.Runtime.Types; namespace IronPython.Runtime.Operations; namespace IronPython.CodeDom;
The TextBox control that I developed to help me understand some unfamiliar python code is IronTextbox. I find it useful to see what IronPython's limits are since it is still in its beta stage. Plus IronPython is staged on a CLI platform and this TextBox control creates more of a non-CLI platform. It currently has three namespacesUIIronTextBox //(the main IronTextBox and IronTextBoxControl namespace)
UIIronTextBox.Paths //(a class to store common paths for the "paths" command)
UIIronTextBox.Utils //(a misc namespace)
UIIronTextBox.IPEWrapper //(a class to handle PythonEngine stream output
Here is a screen capture of the help menu for IronTextBox 1.1.5.0b
In myIronPythonDemo 1.2 try stepping thru some Python code. If you have installed ConceptNet 2.1 (please see my ConceptNet article) click on the "MontyLemmatiser commands" button and this imports MontyREChunker (if your UIIronTextBox.Paths are set correctly) and runs its python method. THIS DEMO WILL ERROR OUT. Set a breakpoint on line 92 in MontyREChunker.py. (you may need to run this first for proper results, as of this writing I am not sure why it does not like to run behind one of the other click events)
Here is a screen shot of Microsoft Visual C# Express 2005 debugging a Python module:
If you download the latest release of the Visual Studio 2005 SDK you may run VS 2005 under it's Experimental Hive which supports IronPython integration. In this mode, it will do Python syntax coloring for you and also auto-indentation.
Below is an incomplete custom MessageBox I wrote to help me debug. It is now located in the UIIronTextBox.Utils namespace.
/// <summary> /// Custom MessageBox call. Excepts some random objects /// from IronPython and converts to string. /// </summary> /// Output object from IronPython. public void MessageBoxIronPy(Object inobject) { Type itstype = inobject.GetType(); switch (itstype.FullName) { case "IronPython.Runtime.Tuple": Tuple IPTuple = new Tuple((Tuple)inobject); MessageBox.Show(IPTuple.ToString()); break; case "IronPython.Runtime.Dict": Dict IPDict = new Dict(); IPDict = (Dict)inobject; MessageBox.Show(IPDict.ToString()); break; case "IronPython.Runtime.List": List IPList = new List(); IPList = (List)inobject; MessageBox.Show(IPList.ToCodeString()); break; case "System.String": MessageBox.Show(inobject.ToString()); break; case "System.Int32": MessageBox.Show(Convert.ToString(inobject)); break; case "System.Collections.Specialized.StringCollection": StringCollection IPSC = new StringCollection(); IPSC = (StringCollection)inobject; StringEnumerator SCE = IPSC.GetEnumerator(); string output = ""; while (SCE.MoveNext()) output += SCE.Current.ToString(); MessageBox.Show(output); break; default: MessageBox.Show (inobject.GetType().ToString() + " not yet implemented."); break; } }
IronPython is Microsoft's answer to handling Python script. It is a great resource to use. It lead me to develop this control for myself. I didn't put too much time into it, but feel free to build upon it or use it to test your own IronPython applications. I envisioned version 1.0.0.0b to include a method for browsing to a Python module and running each line through the IronTextBox but I simply ran out of time. I will be implementing this feature and I will update the article at a later date. IronTextBox 1.1.5.0b currently has "btwfi" command to walk thru a python module to see if any errors occur in IronPython.
| You must Sign In to use this message board. | ||||||
|
||||||
|
||||||
|
||||||
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 26 May 2008 Editor: |
Copyright 2006 by JoeSox Everything else Copyright © CodeProject, 1999-2010 Web19 | Advertise on the Code Project |