Getting rid of the Python console in wxPython on Windows

Possible duplicate:
How to hide a console window in a PyQt application running on Windows?

How to get rid of a console that appears as standard output when running wxPython programs on Windows?

+3
source share
4 answers

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

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

Signature __init__ equals

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

If you set redirect=True and the file name is different from None, sys.stdout and sys.stderr will be redirected to the file name. Note that the default value for Windows and Mac is True. If redirect==True and filename is None , the output will be printed in a pop-up window different from other frames. This can be very useful, so during debugging you can monitor what is happening, but not clutter up the user interface with the internal components of your application in release mode.

+6
source

Not familiar with wxPython, but if you call a script with pythonw.exe and not python.exe, the console window should not appear. I believe that saving the script as script.pyw also works.

+6
source

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.

+6
source

I do not know wxPython, but the solution can be as simple as using pythonw.exe to run the program instead of python.exe .

+3
source

Source: https://habr.com/ru/post/1382424/


All Articles