程序用py2exe转换后立即关闭

问题描述 投票:0回答:1

我有一个带有 tkinter 界面的 python 程序(界面有 3 个按钮,其中一个是退出按钮),它工作得很好。在我将带有 py2exe 的程序转换为 .exe 后,它会在我运行 exe 文件后立即关闭。当我删除退出按钮时,它也可以正常工作,即使是 .exe。

这是我创建的退出按钮:

button_exit = Button(window, text="Exit", command=sys.exit())

如果有人知道这里发生了什么,我将不胜感激。

python tkinter py2exe tkinter-button
1个回答
0
投票

如评论中所述,更改

button_exit = Button(window, text="Exit", command=sys.exit())

button_exit = Button(window, text="Exit", command=sys.exit)
© www.soinside.com 2019 - 2024. All rights reserved.