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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bryan
Sent: Friday, March 23, 2007 11:48 AM
To: users@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@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to