wxPython and Py2exe probs

joc jocdeveloper at hotmail.com
Wed Jul 31 23:58:08 EDT 2002


I found my answers and thought I would post them for anyone
else who gets in the same mess. Solving problem 2 actually
helped me solve problem 1 ;)

2. to be able to write to standard out (the command line)
I wrote the following code
## -----------
# NDPrint.py
import sys

def ndprint( *stuff ):
    for s in stuff:
        sys.__stdout__.write(str(s)+' ')
    sys.__stdout__.write('\n')

if __name__ == '__main__':
    ndprint(1,2,'\thelp', 'me')
## ------------

and changed all my print statements to ndprint (you
need to use brackets () as well) after importing NDPrint.py
sys.__stdout__ holds the file pointer to standard out which
I assume wxPython grabs for sending output to a window.

1. I then wrapped a try/except around the call to wxPythons
app.MainLoop() which printed the traceback using my
ndprint() above.
The reason my app was quitting immediately now became
apparent and was a problem with shelve not finding a dbm
module. I added --includes=dbhash to the command line
calling of py2exe and everything works swimmingly.

Don't you love it when there's a happy ending?

Joc


"joc" <jocdeveloper at hotmail.com> wrote in message
news:ai6815$b5d$1 at news5.svr.pol.co.uk...
> I have 2 questions regarding wxPython and Py2exe
>
> 1. When I try to compile a python script with Py2exe I get the following
> warnings:-
>
>     The following modules were not found: ( I have bunched them to be
easier
> to read)
>
>     cmndlgsc, imagec, clip_dndc, windows3c, filesysc, eventsc, windows2c,
>     controlsc, misc2c, controls2c, os.path, stattoolc, windowsc, mdic,
gdic,
>     sizersc, printfwc, streamsc, framesc, miscc
>
> The exe file runs OK but another script where I try the same just quits
out.
> Both
> scripts run fine with python. (the other script generates more warnings
> because it
> is a lot bigger).
>
> Is my version of python (2.2 on win XP) not set up correctly?
> I have tried using 'python setup.py py2exe --includes imagec' but that
> didn't
> help as py2exe complains that there is no module named that.
>
> 2. I cannot read the error messages because wxPython redirects them to a
> window, which shuts before I can read any output if the program quits.
> Is there a way to get wxWindows to stop this behaviour and to have my
print
> statements and error messages output to standard out?
>
> TIA
>
> Joc
>
>





More information about the Python-list mailing list