root.destroy() 和 root.quit() 有什么区别?

root.destroy() 和 root.quit() 有什么区别?

问题描述:

在Python中使用tkinter,关闭根窗口时root.destroy()root.quit()有什么区别?

In Python using tkinter, what is the difference between root.destroy() and root.quit() when closing the root window?

一个比另一个更受欢迎吗?一个会释放另一个不释放的资源吗?

Is one prefered over the other? Does one release resources that the other doesn't?

quit() 停止 TCL 解释器.在大多数情况下,这就是您想要的,因为您的 Tkinter 应用程序也会停止.这可能是一个问题,如果你例如从空闲状态调用您的应用程序.idle 本身就是一个 Tkinker 应用程序,因此如果您在应用程序中调用 quit() 并且 TCL 解释器被终止, idle 也会终止(或混淆).

quit() stops the TCL interpreter. This is in most cases what you want, because your Tkinter-app will also stop. It can be a problem, if you e.g. call your app from idle. idle is itself a Tkinker-app, so if you call quit() in your app and the TCL interpreter gets terminated, idle will also terminate (or get confused ).

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."

取自 http://www.daniweb.com/forums/thread66698.html