I am using cx_freeze to freeze a tkinter app. When I run the exe I get a wonderfully USELESS console window along with my tkinter GUI.
I would like to remove/hide this useless black window.
I've seen threads that suggest the following:
root = tkinter.Tk()
root.withdraw()
The above code does the opposite of what I want. It hides my GUI, while the useless black window remains. I would like it to be the other way around.
This question is very similar, but for wxPython and cx_Freeze. Fortunately, it turns out that the appearance of the console can be configured from the build script, rather than source code. Borrowing from the top two answers, the trick is setting the base
variable in your cx_Freeze build script:
import sys
from cx_Freeze import setup, Executable
base = None
if (sys.platform == "win32"):
base = "Win32GUI" # Tells the build script to hide the console.
# <The rest of your build script goes here.>
Here is the relevant documentation (although it does not explicitly mention that base
controls the console option).
Also, just because it's interesting, an answer to a different question solves the issue of creating a GUI app with or without a console mode option, which I thought was very cool.
I remember reading somewhere that on Windows if you specify your file extension as .pyw
, it will launch with pythonw.exe (without a console window). Does that work for you?
Do exactly just like gary said, then:
setup(name="ur package name",
version="ur package version",
description="as above",
executables=[Executable("ur_script.py", base=base)]
This will work cx_Freeze
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With