[IronPython] Newbie questions & comments

Edward K. Ream edreamleo at charter.net
Tue Dec 6 16:28:46 CET 2005

> > Are you trying to import the "winforms.py" that is part of the tutorial?
> > [snip]

Running my batch file from the Tutorial directory does indeed make winforms 
available.  Thanks!

Alas, winforms itself does not work properly when started inside my batch 
file.  The window freezes. Here is the contents of my batch file:

cd c:\prog\IronPython-0.9.5\Tutorial
..\bin\IronPythonConsole c:\prog\leoCVS\leo\test\ironPythonTest.py

Here is the contents of the test file that freezes:

print 'Let the wild rumpus start!'

import winforms
from System.Windows.Forms import *
from System.Drawing import *

def click(*args): print args

f = System.Windows.Forms.Form()
f.Click += click

print 'done'

The window appears and 'done' is printed immediately.  However, clicking in 
the window brings up the XP "This program is not responding" window. It 
seems that the following code in winforms.py is not working as expected:

t = Thread(thread_proc)

Here is another attempt:

print 'Let the wild rumpus start!'

import sys
import System

def click(*args): print args

f = System.Windows.Forms.Form()
f.Click += click

print 'done'

In this case the window appears (very fleetingly, I think), and the 'done' 
message appears and that's all.  Presumably this is 'correct': the code 
wasn't run in a separate thread.

Consider the Windows Forms tutorial at:


The c# code is:

namespace Microsoft.Samples.WinForms.Cs.SimpleHelloWorld {
    using System;
    using System.Windows.Forms;

    public class SimpleHelloWorld : Form {

        public static int Main(string[] args) {
            Application.Run(new SimpleHelloWorld());
            return 0;

        public SimpleHelloWorld() {
            this.Text = "Hello World";

Obviously, something involving threads is happening, but a newbie isn't 
going to know how to do this in IronPython.  BTW, I assume eventually there 
will be a Python tab for all these examples :-)

So from my mostly ignorant viewpoint it appears that:

- there is a problem with the thread code in winforms.py

- the IronPython tutorial doesn't tell how to run a Hello World IronPython 
program from a batch file.

Any help would be appreciated.  Thanks.

Edward K. Ream   email:  edreamleo at charter.net
Leo: http://webpages.charter.net/edreamleo/front.html

More information about the Ironpython-users mailing list