-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method #3025
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1543,11 +1543,12 @@ def destroy(self): | |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
self.scale = None | ||
|
||
|
||
def _adjust(self, *args): | ||
|
@@ -1644,5 +1645,8 @@ def set_menu(self, default=None, *values): | |
|
||
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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
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. |
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 thisdestroy()
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.