tkMessageBox returns 'can't invoke "frame" command:' error

Carel Fellinger cfelling at
Fri Jun 25 00:45:39 CEST 1999

Carel Fellinger <cfelling at> wrote:
> though I'm new to python and Tkinter myself, I think I know what the

so, I'm new and reacted to soon

> As for your error message complaining about the frame command not working
> because the application has been destroyed, that's a little trickier.
> Just where should I start...

> First, Tkinter keeps track of the current Tk invocation using the var
> Tkinter._default_root, initially this equals None, and upon invocing
> Tk() it gets initialised. Unfortunately Tkinter doesn't reset this
> var to None upon termination of Tk through an appropriate destroy()!
> (maybe this should be considered a bug? who should know about it?)

I know, I should have read the source. Or the docs.
In I found that Tk.destroy() *does* reset Tkinter._default_root
when appropriate. But elas, this function doesn't get called when you
press the window-close-button without having redefined the window-close
protocol:(. Still a bug in my opinion, but a subtle one. The Tkinter C
module (_tk) provides its own window-close handler. And this one, as can
be read in Lund's excellent albeit slowly growing Tkinter Introduction
docs, doesn't tidy-up the python/tk widget hiearchy. But even if it did,
and according to Lund's docs in future versions it will, this wouldn't
reset Tkinter._default_root to None.

So all in all, just use rootWindow.destroy instead of rootWindow.quit
as command for buttons used to end your script. And use rootWindow.destroy
as the command for the window-close protocol (see Lund's docs).

I sure hope I have it right this time:)

groetjes, carel

More information about the Python-list mailing list