Introduction

The first part of the IronPython Mono Winforms tutorial introduces the Mono platform and the Winforms library.

About this tutorial

This is Mono IronPython Winforms tutorial. Mono IronPython Winforms tutorial is for beginner programmers. The goal of this tutorial is to teach readers basics of GUI programming in Mono Winforms for the IronPython programming language. The tutorial is created and tested on Linux. Nevertheless, it can be used on other operating systems as well. Most examples should run without modification. Images used in this tutorial can be downloaded here.

Mono

Mono is an open development initiative sponsored by Xamarin to develop an open source, UNIX version of the Microsoft .NET development platform. It is a .NET compatible set of tools, which include C# compiler, Common Language Runtime, ADO.NET, ASP.NET and Winforms libraries.

Mono can be divided into three groups:

The core components are the C# language and the Common language runtime. The Gnome development stack includes the GTK# library and various database connectivity libraries. Finally, the Microsoft compatibility stack includes the ADO.NET, ASP.NET and the Winforms libraries.

Mono is multiplatform programming platform. It can be run on Linux, BSD, Mac OS X, Solaris and Windows operating systems. It is a multilanguage effort. For now, only C# language is fully supported. Languages like Visual Basic or IronPython are not yet finished. They are still being developed.

Winforms

Windows Forms is a graphical user interface application programming interface (API) included as a part of Microsoft's .NET Framework. As of 13 May 2008, Mono's System.Windows.Forms 2.0 is API complete. Simply put, Winforms is a library for creating GUI applications.

IronPython

IronPython is an implementation of the Python programming language for the .NET Framework and Mono. IronPython is written entirely in C#. There are some significant differences between Python and IronPython.

Runnning code examples

Our tutorial uses IronPython language.

simple.py
#!/usr/bin/ipy

import clr

clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import Application, Form

class IForm(Form):

    def __init__(self):
        self.Text = 'Simple'
        self.Width = 250
        self.Height = 200
        self.CenterToScreen()

Application.Run(IForm())

This small code example shows a simple window on the screen. It uses the Winforms library. It is coded in IronPython.

#!/usr/bin/ipy

This is the path to the IronPython interpreter.

$ chmod +x simple.py
$ ./simple.py

We make the script executable and run it.

Reference

This was an introduction to the Mono IronPython Winforms.