Hide console window with Tkinter and cx_Freeze

后端 未结 7 1696
南方客
南方客 2020-12-03 03:52

I am using cx_freeze to freeze a tkinter app. When I run the exe I get a wonderfully USELESS console window along with my tkinter GUI.

I would like to remove

7条回答
  •  盖世英雄少女心
    2020-12-03 04:29

    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 sys
    from cx_Freeze import setup, Executable
    
    base = None
    if (sys.platform == "win32"):
        base = "Win32GUI"    # Tells the build script to hide the console.
    
    # 
    

    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.

提交回复
热议问题