sorry, I totally forgot to answer in the last thread :confused:
Ok, your second question is an easy one ;)
import Tkinter as tk
if tkMessageBox.askokcancel("Quit", "You want to quit now? *sniff*"):
root = tk.Tk()
Ok, now the quit - delete one:
I didn't find anything about this in the docs. What I found was confused people who asked the same question, getting no or confusing answers.
Here's what I think:
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.
As I said, this is what I think, don't believe it, maybe I'm wrong ;)
looks like root.destroy() would be the safer way to exit Tkinter. I don't use IDLE very often, I am a DrPython addict, but managed to freeze up IDLE a few times in the past. I checked back on that, and indeed it's associated with the use of root.quit(). Now it makes a lot more sense!
It's a good question, and my own private peace with it is that .destroy() appears to be more general: widgets and frames can be destroyed without destroying the parent, but if you .quit() anywhere within the widget tree, it appears to kill the whole toplevel.
Here's some sample code. The first button merely destroys itself; the
second button is nasty :eek:.