Skip to content

Commit 33460fa

Browse files
authored
ttk: fix LabeledScale and OptionMenu destroy() method (#3025) (#3030)
bpo-31135: Call the parent destroy() method even if the used attribute doesn't exist. The LabeledScale.destroy() method now also explicitly clears label and scale attributes to help the garbage collector to destroy all widgets. (cherry picked from commit cd7e9c1)
1 parent e93135d commit 33460fa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Lib/tkinter/ttk.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,11 +1543,12 @@ def destroy(self):
15431543
try:
15441544
self._variable.trace_vdelete('w', self.__tracecb)
15451545
except AttributeError:
1546-
# widget has been destroyed already
15471546
pass
15481547
else:
15491548
del self._variable
1550-
Frame.destroy(self)
1549+
super().destroy()
1550+
self.label = None
1551+
self.scale = None
15511552

15521553

15531554
def _adjust(self, *args):
@@ -1647,5 +1648,8 @@ def set_menu(self, default=None, *values):
16471648

16481649
def destroy(self):
16491650
"""Destroy this widget and its associated variable."""
1650-
del self._variable
1651-
Menubutton.destroy(self)
1651+
try:
1652+
del self._variable
1653+
except AttributeError:
1654+
pass
1655+
super().destroy()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ttk: fix the destroy() method of LabeledScale and OptionMenu classes.
2+
Call the parent destroy() method even if the used attribute doesn't
3+
exist. The LabeledScale.destroy() method now also explicitly clears label and
4+
scale attributes to help the garbage collector to destroy all widgets.

0 commit comments

Comments
 (0)