Question

Possible Duplicate:
How can I hide the console window in a PyQt app running on Windows?

How to get rid of the console that shows up as standard output when running wxPython programs in Windows?

Was it helpful?

Solution

Others have already suggested of renaming from py to pyw. If you instead refer to Output redirection pass redirect=True when creating the wx.App class.

See for instance http://www.wxpython.org/docs/api/wx.App-class.html

The signature of __init__ is

__init__(self, redirect=False, filename=None, useBestVisual=False, clearSigInt=True)

If you set redirect=True and filename different from None, sys.stdout and sys.stderr will be redirect to filename. Note that on Windows and Mac redirect default value is True. If redirect==True and filename is None, the output will be printed in a popup window different from your other frames. This can be very useful so that while debugging you can follow what is happening, while not cluttering the user interface with the internals of your app in release mode.

OTHER TIPS

Not familiar with wxPython, but if you invoke your script with pythonw.exe rather than python.exe, the console window shouldn't appear. I believe saving the script as script.pyw also works.

The easiest way to do this:

if __name__ == "__main__":
    app = wx.App(0) #<--- or False
    frame = MyFrame('My Frame')
    frame.Show(True)
    app.MainLoop()

This prints to stdout instead of the wxPython window.

I don't know wxPython but the solution might be as simple as using pythonw.exe to run the program instead of python.exe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top