[Tkinter-discuss] re: how to delete a toplevel window from within it?
Jared Cohen
Jared.Cohen at noaa.gov
Fri Jan 7 23:00:06 CET 2005
>
>
> I tried the
>following method, invoked by a button, without success
>
># in FileEditor.py:
>...
> def close(self):
> '''close the window that we live in'''
> self.destroy()
>...
>but the following error is returned:
>AttributeError: Editor instance has no attribute 'destroy'
>
The problem is simple: the Tkinter Toplevel is the only widget that HAS
a method called destroy(). Unless your FileEditor class actually
inherits from the Toplevel widget, it can't be destroyed directly.
However, you can define a destroy() method in your FileEditor that
simply passes along the command to the Toplevel's destroy() method; for
example:
class FileEditor:
def destroy(self):
self.toplevel.destroy()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20050107/4a8402bc/attachment.htm
More information about the Tkinter-discuss
mailing list