How to terminate a TkinterApp correctly?
Gregor Lingl
glingl at aon.at
Sat Aug 16 15:42:08 EDT 2003
Michael Peuser schrieb:
> ----- Original Message -----
> From: "Gregor Lingl" <glingl at aon.at>
> Newsgroups: comp.lang.python
> Sent: Saturday, August 16, 2003 3:53 PM
> Subject: Re: How to terminate a TkinterApp correctly?
>
> ....
>
>
>>Thanks for your remarks and your example. The
>>following solution finally did it:
>>
>>def exit():
>> global done
>> done = True # so the animation will terminate, but
>> # not immediately! The actual pass through
>> # the loop has to be finished.
>> print "done!"
>> import sys
>> # after_idle seems to be crucial! Waits for terminating
>> # the loop (which is in a callback function)
>> cv.after_idle(sys.exit, (0,))
>
>
>
> Why don't you just return? The mainloop can handle everything!?
> Example:
> def exit(self):
> self.done=1
> return
Here I apparently don't understand something fundamental:
What is the effect of a return statement as the last statement
of a function?
When I put this exit into the cv.master.protocol call as shown below,
I cannot close the application at all. (I think it's clear to me why)
Regards, Gregor
> (If you can put it into an appropriate class ....)
>
>
>>cv.master.protocol("WM_DELETE_WINDOW", exit)
>>
>>if not usingIDLE:
>> root.mainloop()
>>
>>Regards, Gregor
>>
>
>
>
More information about the Python-list
mailing list