-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-128562: Fix tkinter widget instance name sometimes duplicated on inherited class #128604
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
Merged
serhiy-storchaka
merged 11 commits into
python:main
from
Xiaokang2022:fix-tkinter-widget-name
Jan 13, 2025
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
37a36a1
fix: Fixed a bug with auto-naming
Xiaokang2022 b46da92
📜🤖 Added by blurb_it.
blurb-it[bot] 2478aa4
refactor: Refactor the solution
Xiaokang2022 d0c90b7
fix: Use the better solution
Xiaokang2022 2e68dec
test: Add tests
Xiaokang2022 8353a11
fix
Xiaokang2022 4e9d5f1
Change "$" to "!"
Xiaokang2022 30e1ee3
Improve some tests
Xiaokang2022 078c5fc
Update Lib/test/test_tkinter/test_misc.py
Xiaokang2022 60b162a
Improve the test
Xiaokang2022 70f1f23
Update Misc/NEWS.d/next/Library/2025-01-08-03-09-29.gh-issue-128562.M…
serhiy-storchaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2025-01-08-03-09-29.gh-issue-128562.Mlv-yO.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix the bug that the widgets of :mod:`tkinter` are named inaccurately. | ||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This works, but it's a little hacky, and probably going to lead to some unexpected results. The more ideal solution would be to actually check if the autogenerated name exists and then adjust accordingly (e.g.
label2
could becomelabel2_2
).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.
However, this will cause the
_name
of the original normal widgets to be changed, which may lead to other incompatibilities. I'd prefer to just modify the name of the inherited class.I now think that if the class name ends with a number, then we might be best able to put a special tag (This tag cannot appear in the class name) after its name. This may be a better solution. (e.g.
label2
->label2$
)What do you think of this solution?
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.
The existing test code requires that the name must be a valid identifier. So there may not be a way to do that.I'm not quite sure what to do right now is the best thing to do. :(Sorry, I read it wrong, the existing test code requires that name is not a valid identifier.