How can I hide the console window in a PyQt app running on Windows?
I think you should be able to run your app with pythonw.exe.
How do i hide the console window for my app?
Use pythonw.exe instead of python.exe
Hiding console window of Python GUI app with py2exe
Yep, it is possible.
If I use
setup(console=['__main__.py'], options={"py2exe":{"includes":["sip"]}})
It creates a console app, however if I use
setup(windows=['__main__.py'], options={"py2exe":{"includes":["sip"]}})
it does not show console on .exe file. But output is dumped on main.exe.log file in the .exe folder. Be careful.
Hiding the console while executing a script on Windows
The way I've done it on Windows 7 is by making a shortcut (or link) that runs my script with the pythonw.exe
interpreter, which has no console, instead of the default python.exe
.
Just follow these 3 steps:
- First create a normal shortcut to your script. One way to do this is to drag the icon for the script file shown in an Explorer window to where you want the shortcut to be (like the desktop) and hold down the Alt key when releasing the mouse button.
- Right-click on the just created shortcut and select
Properties
from the the menu that pops-up. - A Properties dialog for the shortcut will appear. In it insert
C:\python27\pythonw.exe
and a space before the path to the your script file. if the path to your script has any spaces in it, it must now be enclosed in double quotes._ If you're using another version of Python, you'll also need to change thePython27
accordingly.
i.e. A target of D:\path with spaces in it to\myscript.py
would need to be changed
to C:\Python27\pythonw.exe "D:\path with spaces in it to\myscript.py"
You can also change the shortcut's icon here if you wish.
Here's an example:
Update - simpler way: You can also change the extension of your script to .pyw
which will cause it to be run with the pythonw.exe
instead of the python.exe
.
Getting rid of Python console in wxPython under Windows
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.
Hide the console of an .exe file created with PyInstaller
Did you try --windowed
command line flag ?
Related Topics
Find First Sequence Item That Matches a Criterion
Pandas Group by and Find First Non Null Value for All Columns
When Should I Subclass Enummeta Instead of Enum
Executing Multiple Statements with Postgresql via SQLalchemy Does Not Persist Changes
What Is the _Dict_._Dict_ Attribute of a Python Class
Subprocess Readline Hangs Waiting for Eof
Correct Way to Implement a Custom Popup Tkinter Dialog Box
Executing Command Using Paramiko Exec_Command on Device Is Not Working
Pandas: Looking Up the List of Sheets in an Excel File
Numpy - Create Matrix with Rows of Vector
Generating Random Dates Within a Given Range in Pandas
How to Use SQL Parameters with Python
Add Sum of Values of Two Lists into New List
How to Open a File for Exclusive Access in Python
Why Sum on Lists Is (Sometimes) Faster Than Itertools.Chain
What Is the Recommended Way of Allocating Memory for a Typed Memory View