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

拈花ヽ惹草 提交于 2020-02-01 03:31:10

问题


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:


回答1:


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
) 


来源:https://stackoverflow.com/questions/29650935/cx-freeze-help-is-there-a-way-to-not-make-console-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!