mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
ttk: fix LabeledScale and OptionMenu destroy() method (#3025)
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.
This commit is contained in:
parent
733d0f63c5
commit
cd7e9c1b67
2 changed files with 12 additions and 4 deletions
|
@ -1543,11 +1543,12 @@ class LabeledScale(Frame):
|
|||
try:
|
||||
self._variable.trace_vdelete('w', self.__tracecb)
|
||||
except AttributeError:
|
||||
# widget has been destroyed already
|
||||
pass
|
||||
else:
|
||||
del self._variable
|
||||
Frame.destroy(self)
|
||||
super().destroy()
|
||||
self.label = None
|
||||
self.scale = None
|
||||
|
||||
|
||||
def _adjust(self, *args):
|
||||
|
@ -1644,5 +1645,8 @@ class OptionMenu(Menubutton):
|
|||
|
||||
def destroy(self):
|
||||
"""Destroy this widget and its associated variable."""
|
||||
del self._variable
|
||||
Menubutton.destroy(self)
|
||||
try:
|
||||
del self._variable
|
||||
except AttributeError:
|
||||
pass
|
||||
super().destroy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue