]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add calls to self.protocol("WM_DELETE_WINDOW", self.destroy) to the Tk
authorGuido van Rossum <guido@python.org>
Fri, 20 Aug 1999 18:26:06 +0000 (18:26 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 20 Aug 1999 18:26:06 +0000 (18:26 +0000)
and Toplevel class constructors.  This means that if the window
manager closes the window, the Python-side Tkinter data structures
will be destroyed correctly.  (Most apps do this anyway, and it's
recommended practice; I see no reason why making it the default
behavior could be bad.)

Lib/lib-tk/Tkinter.py

index 8d06ef16a57cfe82f9a32df0f344ffbe1402cc96..76745910d18c9ff3eef56c849e6bed3d926c15af 100644 (file)
@@ -910,6 +910,7 @@ class Tk(Misc, Wm):
                self.readprofile(baseName, className)
                if _support_default_root and not _default_root:
                        _default_root = self
+               self.protocol("WM_DELETE_WINDOW", self.destroy)
        def destroy(self):
                for c in self.children.values(): c.destroy()
                self.tk.call('destroy', self._w)
@@ -1119,6 +1120,7 @@ class Toplevel(BaseWidget, Wm):
                root = self._root()
                self.iconname(root.iconname())
                self.title(root.title())
+               self.protocol("WM_DELETE_WINDOW", self.destroy)
 
 class Button(Widget):
        def __init__(self, master=None, cnf={}, **kw):