Hiding command-line dialog in py2exe

后端 未结 2 988
醉话见心
醉话见心 2020-12-18 11:39

Hi When I compile my python script with py2exe, everything works well except a usless command-line dialog appears as well as my GUI. Any way to fix this? I have python 2.7 a

相关标签:
2条回答
  • 2020-12-18 12:20

    Using setup(windows=['Main.py']) should remove the command line dialog and use Main.py as your console, instead.

    0 讨论(0)
  • 2020-12-18 12:21

    Rename your entry point python script extension from .py to .pyw and regenerate your exe.

    Example: python -m py2exe.build_exe -b 0 my_script.pyw

    (tested with Python 3.4.3 on Windows 8.1 x64)

    Example: my_script.pyw

    import ctypes
    MessageBox = ctypes.windll.user32.MessageBoxW
    MessageBox(None, 'Hello', 'Hello Window Title', 0)
    

    You should not see a command prompt for this GUI application.

    0 讨论(0)
提交回复
热议问题