cx_Freeze help: is there a way to NOT make console open?

Dalex picture Dalex · Apr 15, 2015 · Viewed 10.5k times · Source

I am trying to convert a python game (made with pygame) into a exe file for windows, and I did using cx_Freeze. No problems there.
The thing is that when I launch myGame.exe, it opens the normal Pygame window and a console window(which I do not want).

Is there a way to remove the console window? I read most of the documentation, but I saw nothing really (except base, but I don't get what that is).

BTW, here is my setup file:

import cx_Freeze

exe = [cx_Freeze.Executable("myGame.py")]

cx_Freeze.setup(
    name = "GameName",
    version = "1.0",
    options = {"build_exe": {"packages": ["pygame", "random", "ConfigParser", "sys"], "include_files": [
    "images", "settings.ini", "arialbd.ttf"]}},
    executables = exe
)  

Here's a screen shot of what happens when I launch the exe: ScreenShot

Answer

Dalex picture Dalex · Apr 16, 2015

So what was wrong, was that the setup.py file was missing a parameter.
What you need to add is base = "Win32GUI" to declare that you do not need a console window upon launch of the application.
Here's the code:

import cx_Freeze

exe = [cx_Freeze.Executable("myGame.py", base = "Win32GUI")] # <-- HERE

cx_Freeze.setup(
    name = "GameName",
    version = "1.0",
    options = {"build_exe": {"packages": ["pygame", "random", "ConfigParser", "sys"],  
        "include_files": ["images", "settings.ini", "arialbd.ttf"]}},
    executables = exe
)