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
cd7e9c1b67d3d07ee03e0a79af2791c19031cecb)
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):
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()
--- /dev/null
+ttk: fix the destroy() method of LabeledScale and OptionMenu classes.
+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.