Answer a question

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?

Answers

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

taken from http://www.daniweb.com/forums/thread66698.html

Logo

学AI,认准AI Studio!GPU算力,限时免费领,邀请好友解锁更多惊喜福利 >>>

更多推荐