Hide console window with Tkinter and cx_Freeze Hide console window with Tkinter and cx_Freeze tkinter tkinter

Hide console window with Tkinter and cx_Freeze


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?


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 sysfrom cx_Freeze import setup, Executablebase = Noneif (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.


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