Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e61e98d

Browse files
committed
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.)
1 parent 5c9eb21 commit e61e98d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/lib-tk/Tkinter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ def __init__(self, screenName=None, baseName=None, className='Tk'):
910910
self.readprofile(baseName, className)
911911
if _support_default_root and not _default_root:
912912
_default_root = self
913+
self.protocol("WM_DELETE_WINDOW", self.destroy)
913914
def destroy(self):
914915
for c in self.children.values(): c.destroy()
915916
self.tk.call('destroy', self._w)
@@ -1119,6 +1120,7 @@ def __init__(self, master=None, cnf={}, **kw):
11191120
root = self._root()
11201121
self.iconname(root.iconname())
11211122
self.title(root.title())
1123+
self.protocol("WM_DELETE_WINDOW", self.destroy)
11221124

11231125
class Button(Widget):
11241126
def __init__(self, master=None, cnf={}, **kw):

0 commit comments

Comments
 (0)