[ACCEPTED]-Hide console window with Tkinter and cx_Freeze-cx-freeze

Accepted answer
Score: 14

I remember reading somewhere that on Windows 3 if you specify your file extension as .pyw, it 2 will launch with pythonw.exe (without a 1 console window). Does that work for you?

Score: 11

This question is very similar, but for wxPython 8 and cx_Freeze. Fortunately, it turns out 7 that the appearance of the console can be 6 configured from the build script, rather 5 than source code. Borrowing from the top 4 two answers, the trick is setting the base variable 3 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 2 relevant documentation (although it does not explicitly 1 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.

Score: 5

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 1 will work cx_Freeze

Score: 2

I had the same problem today

What i was using 11 to compile my python programs was py2exe 10 and the fix was very simple modify the setup 9 file as shown below. My interface is written 8 with Tkinter

modify the "setup.py" py2exe 7 script from:

Old Python Code:

from distutils.core import setup
import py2exe
setup(console=['app.py'])

New Python Code:

from distutils.core import setup
import py2exe
setup(windows=['app.py'])

After 6 i did this and reran my setup script the 5 application loaded and did not show the 4 console window. The only thing with this 3 is if you have your application sending 2 print commands to the console window you 1 will not see theme. I hope this helps.

Score: 2

If using pyinstaller use pyinstaller-gui.py In 10 Windows command line type

python pyinstaller-gui.py

This 9 will first say "Please use just 'pyinstaller.py'. Gui 8 is not maintained." Change the code l'il 7 bit and you will be able to run this.

It 6 will show pop up a window to select your 5 script and some checkboxex. Check on 'no 4 console(windows only)

That's it. You are 3 done!

Another option: use --noconsole option 2 while building. i.e:

python pyinstaller.py 1 --noconsole yourscript.py

Score: 1

I'm assuming by "black window" you are referring 3 to the terminal window. In order to disable 2 this from popping up, save your file as 1 a .pyw extension instead of .py

Score: 1

For me using the option --base-name Win32GUI works. Here is 2 an example:

cxfreeze your_python_file.py 1 --base-name Win32GUI --target-dir your_target_dir

More Related questions