summaryrefslogtreecommitdiffstats
path: root/Lib/lib-tk
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-08-20 18:26:06 (GMT)
committerGuido van Rossum <guido@python.org>1999-08-20 18:26:06 (GMT)
commite61e98d2ae345518f68d199f04f982c331beb210 (patch)
tree92a09f4550c4e70a9a22636d6c34cdc7ef8958bf /Lib/lib-tk
parent5c9eb21729a4fd0334785c6290c8220e484e508c (diff)
downloadcpython-e61e98d2ae345518f68d199f04f982c331beb210.zip
cpython-e61e98d2ae345518f68d199f04f982c331beb210.tar.gz
cpython-e61e98d2ae345518f68d199f04f982c331beb210.tar.bz2
Add calls to self.protocol("WM_DELETE_WINDOW", self.destroy) to the Tk
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.)
Diffstat (limited to 'Lib/lib-tk')
-rw-r--r--Lib/lib-tk/Tkinter.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 8d06ef1..7674591 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -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):