diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-08-08 17:41:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-08 17:41:21 (GMT) |
commit | cd7e9c1b67d3d07ee03e0a79af2791c19031cecb (patch) | |
tree | f3d6e64a14dcbada5a2af799e5bc3f94267c64d3 /Lib/tkinter/ttk.py | |
parent | 733d0f63c562090a2b840859b96028d6ec0a4803 (diff) | |
download | cpython-cd7e9c1b67d3d07ee03e0a79af2791c19031cecb.zip cpython-cd7e9c1b67d3d07ee03e0a79af2791c19031cecb.tar.gz cpython-cd7e9c1b67d3d07ee03e0a79af2791c19031cecb.tar.bz2 |
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.
Diffstat (limited to 'Lib/tkinter/ttk.py')
-rw-r--r-- | Lib/tkinter/ttk.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py index 3ecc004..e1a965e 100644 --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -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() |