The sample code that was developed used the Python console (ipy) and a text editor - in other words with simple text-based tools for writing short scripts. But for bigger projects, or when coding GUIs, a text editor obviously isn't enough.
For more heavy lifting, there's IronPython Studio - a complete (and free) integrated development environment for IronPython with GUI design tools, a debugger and much more. In part two of my look at IronPython, I'll show take you through the tools and tricks of using one of Microsoft's latest .NET development combos.
IronPython Studio is based on Microsoft's free Visual Studio 2008 Shell runtime. It requires .Net Framework 3.5 and the Visual Studio 2008 Shell (isolated mode) Redistributable, as well as the installer that can be downloaded from here. In addition to the IDE, IronPython Studio also includes version 1.1.0 of the IronPython interpreter.
As it uses isolated mode, IronPython Studio doesn't interfere with existing installations of Visual Studio 2005 or 2008. It's also worth noting that it's an open source project - released under the Microsoft Public License - and that the source code is also available for download.
Visually, IronPython Studio presents a familiar look and feel and those who've ever used other versions of Visual Studio should feel quite at home. The usual array of elements that include tools bars, dockable controls, editors and navigation bars are all present and correct.
Clicking on New Project opens a dialog box that offers a choice from four pre-defined templates: Class Library, Console Application, Windows Application and WPF Application, providing the opportunity to code IronPython applications with a GUI front end.
WinForms applications are handled in the usual Visual Studio style, offering both a design view - with controls that can be dragged and dropped into place on a container, property grids where you can view and set properties - and a code view where you can edit code.
The editor provides the usual functionality such as syntax colouring, Intellisense, code navigation functions, error highlighting and bookmarking. It makes creating Python applications for the .NET platform very straightforward, particularly for those developers already versed in the ways of Visual Studio.
Registering event handlers for widgets, for example, is as simple as assigning the handler to the widget. For example a button click handler can be assigned as follows:
self._button1.Click += self._button1_ClickHandler
This is a reference to the bit of Python code that will be called when the button is clicked. IronPython Studio even creates the skeleton code for you when you add a widget to your GUI. Dragging and dropping a button on a form generates the skeleton handler code:
@accepts(Self(), System.Object, System.EventArgs) @returns(None) def _button1_Click(self, sender, e): pass
The pass statement is a "do nothing" command, so replace it with the code to perform the action required.