Python 通过pyinstaller时程序未运行
当我使用Python 通过pyinstaller时程序未运行,python,python-3.x,pyinstaller,Python,Python 3.x,Pyinstaller,当我使用exit时,pyinstaller出现问题,出现错误,程序无法运行。当我使用quit或sys.exit()时,程序不会运行。如果我忽略所有这些,并使用X按钮,线程将在任务管理器中继续运行。我应该使用什么函数来修复此问题? 所需代码 def exitgame(): sys.exit() main = Tk() main.title("Fruit Clicker") main.geometry("400x350+300+100") B
exit
时,pyinstaller出现问题,出现错误,程序无法运行。当我使用quit
或sys.exit()
时,程序不会运行。如果我忽略所有这些,并使用X按钮,线程将在任务管理器中继续运行。我应该使用什么函数来修复此问题?
所需代码
def exitgame():
sys.exit()
main = Tk()
main.title("Fruit Clicker")
main.geometry("400x350+300+100")
Button(main, text="Play", command=rootopen).pack()
Button(main, text="Quit Game", command=exitgame).pack()
提前感谢不用编写退出应用程序的函数,您可以不使用函数直接关闭应用程序,只需将“退出游戏按钮”的“command=exitgame”替换为“command=main.destroy” 示例代码-
from tkinter import *
from tkinter.ttk import *
main = Tk()
main.title("Fruit Clicker")
main.geometry("400x350+300+100")
Button(main, text="Quit Game", command=main.destroy).pack()
mainloop()
您可以不使用函数直接关闭应用程序,而不用编写退出应用程序的函数,只需将“退出游戏按钮”的“command=exitgame”替换为“command=main.destroy” 示例代码-
from tkinter import *
from tkinter.ttk import *
main = Tk()
main.title("Fruit Clicker")
main.geometry("400x350+300+100")
Button(main, text="Quit Game", command=main.destroy).pack()
mainloop()
这是返回的内容:
\u tkinter.TclError:无法调用“按钮”命令:应用程序已被销毁
@AnonymousPupper2006我已使用示例代码更新了我的答案,请尝试并让我知道这是返回的内容:\u tkinter.TclError:无法调用“按钮”命令:应用程序已被销毁
@AnonymousPupper2006我已使用示例代码更新了我的答案,请尝试一下,并让我知道