idle BUG

Mike Clarkson support at internetdiscovery.com
Wed Jun 20 04:07:26 EDT 2001


On Tue, 19 Jun 2001 00:03:49 +0100, Robin Becker
<robin at jessikat.fsnet.co.uk> wrote:

>In article <3b2e552f.2621005 at nntp.ix.netcom.com>, Mike Clarkson
><support at internetdiscovery.com> writes
>....
>>Robin, try this (you'll have to fix the tk.eval lines back up to be
>>all one line). In Tkinter.py, change quit() to
>>
>>    def quit(self):
>>        """Quit the Tcl interpreter. All widgets will be destroyed."""
>>        self.tk.eval('foreach w [winfo child .] {wm protocol $w
>>WM_DELETE_WINDOW {}; catch {destroy $w}}')
>>        self.tk.eval('catch {set w .; wm protocol $w WM_DELETE_WINDOW
>>{}; destroy $w}')
>>        self.tk.quit()
>>
>>If it works for you, I'll explain why it's required under Tkinter, but
>>not Tk.
>>
>>This makes self.quit() do what it's documented to do, and leaves 
>>self.tk.quit (which is _tkinter.quit) to do what it does now, namely
>>signals the mainloop to end but destroys no widgets.
>>
>...
>sorry my app hangs as before. have you got other changes in place?
>>Mike.

No, it's a vanilla ActiveState 2.1, but it's on Windows 98 which
differs a little from Win95. The only change is this self.quit patch.

Make sure you are not calling or binding self.tk.quit() - use the
patched self.quit() instead. self.tk.quit() is the _tkinter quit,
which just says bail out of the self.tk.mainloop(). It doesn't destroy
any windows, delete any Tk intepreter or even delete any of the tcl
commands declared in Python as callbacks. So it's not at all like a Tk
[exit].

If you take idle as an example, after the .mainloop() statement in
PyShell, add the following in main() (NB: console application only):
	root.tk.eval('puts [winfo child .]')
after the 
	root.mainloop()
You'll see that after idle exists its mainloop, there are two Tk
toplevel windows still alive: . and .123456 (some number).
It's because root.tk.quit() does not destroy any windows.

My patched root.quit() makes sure they're all destroyed.
My theory was/is that the undestroyed windows might be
stopping Python from unloading the Tk and exiting cleanly.

Note that the next statement in idle main()
	root.destroy()
doesn't destroy any Tk windows or intepreter. It's an internal
function that deletes the Python callback functions. It should
probably be renamed to _deletetclcallbacks, and maybe even
included in my patched self.quit() before the tk.evals.

Mike.

probably be renamed






More information about the Python-list mailing list