Hello World

From IronPython Cookbook

(Difference between revisions)
Line 17: Line 17:
</pre>
</pre>
-
[Image:Windows-forms-hello-world.jpg|The 'Hello World' Form]
+
[[Image:Windows-forms-hello-world.jpg|The 'Hello World' Form]]
The IronPython distribution comes with some example code in the tutorial directory: ''winforms.py''.  This creates a hidden form, and puts the interactive interpreter on a background thread.
The IronPython distribution comes with some example code in the tutorial directory: ''winforms.py''.  This creates a hidden form, and puts the interactive interpreter on a background thread.

Revision as of 17:00, 27 May 2007

The .NET framework includes a GUI toolkit for writing desktop applications. This is called Windows Forms, and is contained in the System.Windows.Forms assembly.

It is easy to use. The following example creates a form (a window) with a label on it, and can be executed from the interactive interpreter:

import clr
clr.AddReference('System.Windows.Forms')

from System.Windows.Forms import Application, Form, Label

form = Form(Text="Hello World Form")
label = Label(Text="Hello World!")

form.Controls.Add(label)

Application.Run(form)

The 'Hello World' Form

The IronPython distribution comes with some example code in the tutorial directory: winforms.py. This creates a hidden form, and puts the interactive interpreter on a background thread.

TOOLBOX
LANGUAGES