[英]Tkinter application restart
我有一个应用程序编写的类,我想用一个按钮重新启动
import sys
import os
from tkinter import Tk, Label, Button
def restart_program():
"""Restarts the current program.
Note: this function does not return. Any cleanup action (like
saving data) must be done before calling this function."""
python = sys.executable
os.execl(python, python, * sys.argv)
root = Tk()
Label(root, text="Hello World!").pack()
Button(root, text="Restart", command=restart_program).pack()
root.mainloop()
我正在使用我在一个线程上找到的代码,但这只是退出程序并且不会重新启动它
我的代码太长了,但它包含一个包含我的应用程序所有函数的类
我想重新启动应用程序,以便所有小部件都被销毁
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.