11

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

Dalex
  • 359
  • 2
  • 3
  • 12
  • Change the name of "myGame.py" to "myGame.pyw". See http://stackoverflow.com/questions/12121033/python-terminal-window-popping-up-at-pygame-app-run for details. Also of interest: http://stackoverflow.com/questions/7012444/disable-the-pygame-console-output – PM 2Ring Apr 15 '15 at 13:14

2 Answers2

21

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
) 
PM 2Ring
  • 54,345
  • 6
  • 82
  • 182
Dalex
  • 359
  • 2
  • 3
  • 12
1

The parameter can be passed also by the shell if you are making a quick executable like this:

cxfreeze my_program.py --base-name=WIN32GUI
piertoni
  • 1,933
  • 1
  • 18
  • 30