程序在使用py2exe转换后立即关闭。

huangapple go评论51阅读模式
英文:

Program closes instantly after converting it with py2exe

问题

I have a python program with a tkinter interface (the interface has 3 buttons, one of them is an exit button) which works perfectly fine. After i convert the program with py2exe to an .exe it instantly closes after i run the exe file. When i delete the exit button, it works also fine, even as a .exe.

This is the Exit button I created:

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

If anyone has a clue whats going on here i would be very grateful.

英文:

I have a python program with a tkinter interface (the interface has 3 buttons, one of them is an exit button) which works perfectly fine. After i convert the program with py2exe to an .exe it instantly closes after i run the exe file. When i delete the exit button, it works also fine, even as a .exe.

This is the Exit button I created:

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

If anyone has a clue whats going on here i would be very grateful.

答案1

得分: 1

如评论中所述,将

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

更改为

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

As mentioned in a comment, change

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

to

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

huangapple
  • 本文由 发表于 2023年4月19日 22:56:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055976.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定