SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Matt Ward

IronPython Integration In SharpDevelop 2.2

Support for IronPython 1.1 is now available for SharpDevelop The IronPython addin is an early alpha release and is not an official part of SharpDevelop 2.2.1 so it is available as a separate download at the end of this post.

The addin will not work with SharpDevelop 3.0 nor IronPython 2.0.


  • Code folding
  • Syntax highlighting
  • File and project templates for Console and Windows Forms applications
  • Code completion (limited)
  • Windows Forms designer
  • C# and VB.NET code conversion to Python

Please note that code completion, the forms designer and code conversion all need a lot more work.

Creating a Windows Application

Open up the new project dialog by selecting New then Solution from the File menu. Selecting the Python category will show two project templates. One will create a Windows console application and the other will create a Windows Forms application.

New Python Project Dialog

Once you have created a new project you will then need to add a reference to the IronPython assembly. Open the Projects window by selecting Projects from the View menu. In the Projects window, right click the project and select Add Reference. Select the .NET Assembly Browser tab and click the Browse button. Then browse to IronPython.dll. The addin includes this file so can either extract it from there or if you installed it from the sdaddin file then you should be able to find the IronPython.dll in the folder:


C:\Documents and Settings\[YourUserName]\Application 

To build the application select Build Solution from the Build menu.

The built executables cannot be run with the debugger so instead select Run without debugger from the Debug menu. If you are running a windows app and nothing seems to happen then open a command line window and run it from there. This way you should see any errors reported from the IronPython runtime.

There are a few file templates which can be added to the project as shown below.

Designing Windows Forms

The Windows Forms designer is still in its early stages so please be warned that it may break the form's code or worse. Most of the Windows Forms controls work with the designer but things like adding columns to a list view will generate code that does not compile.

The designer can be opened in the usual way by opening the form in the text editor and selecting the Design tab at the bottom of the text editor.

Python main form before opening the designer

Once open in the designer you can add controls to the form in the usual way from the Tools window. In the screenshot below a label, text box and a button have been added.

Main form designed in designer

Click the Source tab to view the generated code in the InitializeComponents method.

Generated form code

Code Folding

Code folding allows you to collapse regions of a class.

Folded python code

Code Completion

Code completion is very limited currently. If you type a space after an import statement then you will get a list of namespaces available.

Import code completion

Code completion for classes is one area which has the most limited support. If you open you can get code completion for static classes such as System.Console but it does not work everywhere.

Console.WriteLine code completion

Method insight for Python

Code Conversion

To convert VB.NET or C# to Python open the file you want to convert and then select Convert code to Python from the Tools menu.

Convert code to Python menu item

The code conversion is limited to classes so it will not convert an arbitary piece of code that is not inside a class. A C# class being converted to Python is shown below.

C# code before converting to Python

Converted Python code

The code conversion is still at an early stage of development so it will fail on complicated classes.

Class View

Classes in the open solution will be displayed in the Class browser (Select Classes from the View menu).

Python class in Classes window

From there you can double click a class or method and the text editor will display the corresponding code.

Standalone Python Files

The addin has support for standalone Python files. If you open a file with a .py file extension then a Python menu will appear.

Python menu items

From this menu you can run ipy.exe and have it execute the file. Any output from the Python script will be shown in the Output window.

By default the ipy.exe run is the one that ships with the addin. You can choose another IronPython console by select Options from the Tools menu. Selecting the Python option allows you to choose another IronPython console.

Python options dialog

Installing the IronPython AddIn

  1. Rename the file to IronPythonAddIn-0.2.1.sdaddin.
  2. From the Tools menu select AddIn Manager .

    Tools AddIn Manager menu item

  3. Click the Install AddIn button.

    AddIn Manager dialog

  4. In the Open File Dialog browse to the IronPythonAddIn-0.2.1.sdaddin file and click the Open button.

    AddIn installed confirmation dialog.

  5. Click the Close button.
  6. Restart SharpDevelop.

Future Work

Since SharpDevelop is the last release in the 2.x branch the next release of the IronPython addin will be for SharpDevelop 3.0 and it will support IronPython 2.0.

Python Links

Some of the Python tutorials and links used whilst creating the IronPython addin.

  1. Python documentation by Guido van Rossum the author of Python.
  2. Dive into Python book by Mark Pilgrim. The full text is available online.
  3. IronPython homepage.





IronPython agora ?? suportado por pelo SharpDevelop (2.2) « Inno::Blog /* by Alberto Fabiano */ said:

October 22, 2007 5:18 AM

fellmad said:

Way, way cool. I'm going to install sharpdevelop (again) on my home machine ASAP. It has the VS2008 beta2 stuff, but this just rocks.


October 22, 2007 11:12 PM

djlawler said:

Very nice!  I did have to add:

import clr



to the top of (or maybe I missed something)?

Will the source code be available?



October 25, 2007 2:43 PM

MattWard said:

If you run the IronPython WinForms application by selecting Run without debugger from the Debug menu then the three lines of code you added are not needed since the application is compiled into an executable. Whereas running the application by selecting Run from the Python menu runs with the IronPython console (ipy.exe) will fail unless those three lines of code are added. I'll add these lines of code to the template since the application will then work in both cases.

The source code was supposed to be attached to this post but CommunityServer only supports one attachment per post. I'm planning to do a IronPython Internals post that takes a look at the source code and includes the code as an attachment.

October 25, 2007 8:41 PM

djlawler said:

Great, thanks this is very promising already.  I don't know if it is too early for 'bug reports', but three things I noticed already were:

1. Triple quoted doc strings really mess up the ability of the designer to work (as I am sure you are aware it is a little fragile anyway :) - all you have to do is design a form and then put in """ This form is cool """ at the top and...bang.

2. Second, when working on a form it sometimes creates an resx file 'under' the python module that contains the form.  I have to keep removing the resource file and putting any resources that it created in it back into the main python code.

3. Third - and this might be my prejudice - but I don't like tabs in python.  I prefer spaces as they create fewer problems.  I have to remember to go into Tools,Options,Text Editor,Behavior and check 'Convert Tabs to Spaces'.  I like to use tabs in VB and C# so it would be nice if Python could override this setting for Python files?

If I could get to the source I might be able to help.  I have found the SharpDevelop Addin stuff hard to follow in the past....but I have some experience using the ICSharpCode.TextEditor in a 'fun' IronPython project and am gradually understanding things

October 25, 2007 10:40 PM

MattWard said:

Bug reports are welcome. I'll look at 1) and 2).

As for 3) these text editor settings are global settings and are independent of the currently active project or file. I'm not sure that switching it based on the active file would be a good idea.

October 27, 2007 1:24 PM

mosenturm said:

Thanks for this AddIn!

So I have some trouble with the forms designer.

When I create in with the designer a form with a statusstrip and a toolStripStatusLabel the designer isn't working after closing #develop and starting it again. The designer is showing me only an empty form.

Again, thanks for the great AddIn!


November 15, 2007 12:55 PM

MattWard said:

Adding a StatusStrip and a ToolStripStatusLabel worked for me. The only way I could reproduce your problem was to add an event handler for a toolstrip label or a menu item. If you comment out the event handler assignments, for example:

self._toolStripStatusLabel2.Click += self.ToolStripStatusLabel2Click

then I could get the designer to work again.

Please note that this adding is still an alpha and the forms designer has not completely finished yet. But thanks for the bug report and I will look into fixing the problem.

November 18, 2007 5:44 PM

Reflective Perspective - Chris Alcock » The Morning Brew #124 said:

Pingback from  Reflective Perspective - Chris Alcock  » The Morning Brew #124

June 27, 2008 9:25 AM

Matt Ward said:

Support for IronPython 2.0 Beta 4 is now available with SharpDevelop 3. Missing Features Some of the

August 20, 2008 10:32 PM
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this ( email address.