restartButton = ttk.Button(text = "RESTART?", command = restartProgram)
restartButton.place(x = 400, y = 100, width = 200, height = 40)
def restartProgram():
os.execl(sys.executable, os.path.abspath('Game.py'), *sys.argv)
这是我在重启程序时能找到的最接近的代码。但是,这段代码只打开了'Shell‘,并没有重新启动程序。
有没有人知道通过点击按钮重新启动程序的方法
https://stackoverflow.com/questions/50319970
复制相似问题