mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.)
This commit is contained in:
parent
5c9eb21729
commit
e61e98d2ae
1 changed files with 2 additions and 0 deletions
|
@ -910,6 +910,7 @@ class Tk(Misc, Wm):
|
||||||
self.readprofile(baseName, className)
|
self.readprofile(baseName, className)
|
||||||
if _support_default_root and not _default_root:
|
if _support_default_root and not _default_root:
|
||||||
_default_root = self
|
_default_root = self
|
||||||
|
self.protocol("WM_DELETE_WINDOW", self.destroy)
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
for c in self.children.values(): c.destroy()
|
for c in self.children.values(): c.destroy()
|
||||||
self.tk.call('destroy', self._w)
|
self.tk.call('destroy', self._w)
|
||||||
|
@ -1119,6 +1120,7 @@ class Toplevel(BaseWidget, Wm):
|
||||||
root = self._root()
|
root = self._root()
|
||||||
self.iconname(root.iconname())
|
self.iconname(root.iconname())
|
||||||
self.title(root.title())
|
self.title(root.title())
|
||||||
|
self.protocol("WM_DELETE_WINDOW", self.destroy)
|
||||||
|
|
||||||
class Button(Widget):
|
class Button(Widget):
|
||||||
def __init__(self, master=None, cnf={}, **kw):
|
def __init__(self, master=None, cnf={}, **kw):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue