Skip to main content
 首页 » 编程设计

python之我可以使用 sys.exit() 来停止 Tkinter 程序吗

2024年10月24日11mate10pro

使用 sys.exit() 停止 Tkinter 程序是否有问题?

我知道人们通常使用 root.destroy() 这是为什么?

请您参考如下方法:

当然可以,但它会终止整个程序,包括您的应用。

根据这里:https://www.daniweb.com/programming/software-development/threads/66698/exit-a-tkinter-gui-program . root.destroy 是一种安全、可靠的退出 Tkinter 应用程序的方法。来自链接:

destroy() just terminates the mainloop and deletes all widgets. So it seems to be safer if you call your app from another Tkinter app, or if you have multiple mainloops.