Tkinter: Making a window disappear

Eric Brunel eric_brunel at despammed.com
Tue Oct 10 10:42:16 CEST 2006


On Mon, 09 Oct 2006 11:08:39 +0200, Claus Tondering  
<claus.tondering at gmail.com> wrote:

> I just solved the problem myself:
>
> I wrote:
>>             self.destroy()
>
> Writing "self.master.destroy()" instead does the trick.

As an alternative (which is better IMHO), you may consider specializing  
Toplevel instead of Frame for your dialog:

class MyDialog(Toplevel):
   ...

In tk/Tkinter, a Frame is a generic container for widgets; it is not what  
is usually called a window. Creating an instance of Frame when there is no  
window to contain it happens to create a new one, but it is a side-effect,  
and you should not rely on it.

Once you've done that, you can simply write:

self.destroy()

to delete the window.

> Sorry for the inconvenience.

No problem.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list