[IronPython] compiling

Dino Viehland dinov at exchange.microsoft.com
Fri Mar 23 23:35:43 CET 2007


I think the problem is we're not setting the module name to __main__. If I do this with:

import clr

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

from System.Windows.Forms import MessageBox

MessageBox.Show(__name__)

>From 'hello.py' the message box shows 'hello'.

I believe this is the same as bug #2537 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=2537).  Currently the bug has 0 votes so we haven't been paying too much attention to it to date.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Bryan
Sent: Friday, March 23, 2007 11:48 AM
To: users at lists.ironpython.com
Subject: [IronPython] compiling

hi,

i just wrote my first ipy script and i have some questions.

# hello.py

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

def show():
    WinForms.MessageBox.Show('Hello', 'Hello World')

if __name__ == '__main__':
    show()


when i execute the following

c:\> ipy -X:SaveAssemblies hello.py

a hello.exe file is generated and i can successfully execute it.

but when i compile with pyc as follows:

c:\> ipy pyc /main:hello.py
Input Files:
    hello.py
Resource Files:
Output:
    hello.exe
Target:
    ConsoleApplication

-or-

c:\> ipy pyc /main:hello.py /target:winexe
Input Files:
    hello.py
Resource Files:
Output:
    hello.exe
Target:
    WindowApplication

it generates hello.exe, but the program doesn't run (the MessageBox doesn't
display).  i even tried explicitly adding /r:System.Windows.Forms without
luck.  what am i doing wrong?


thanks,


bryan





_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list