-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method #3025
Conversation
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.
pass | ||
else: | ||
del self._variable | ||
Frame.destroy(self) | ||
super().destroy() | ||
self.label = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not del
them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike when attributes "disappear". I prefer setting them to None. Moreover, "self.label = None" doesn't fail if destroy() is called twice, whereas "del self._variable" requires a try/except AttributeError.
pass | ||
else: | ||
del self._variable | ||
Frame.destroy(self) | ||
super().destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parent's destroy()
now is called even if this destroy()
already was called. I.e. it can be called twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a deliberate choice. All other ttk widgets now have the same behaviour.
Call the parent destroy() method even if the used attribute doesn't
exist.
https://bugs.python.org/issue31135