-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-43457: Tkinter: fix design flaws in wm_attributes() #111404
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
gh-43457: Tkinter: fix design flaws in wm_attributes() #111404
Conversation
* w.wm_attributes() without arguments returns a dict instead of a tuple or a str. * When called with a single argument to get a value, it allow to omit the minus prefix. * It can be called with keyword arguments to set attributes.
To me, the changes are all good and at least a decade overdue. For instance, it upgrades w.wm_attributes to work like w.config. This issue comment gives more details. The sticky part is immediately changing the return object of a no-arg call. This should be a plus for interactive uses and for new programmatic uses. However, it will break existing code that probes the structure of the return object. The default requirement of PEP 387 is a deprecation period. The alternative (the last sentence): "If a warning cannot be provided to users, consult with the steering council." In this case, () cannot both give the old return with a warning and give the new return. So giving a warning would mean either not returning a dict until 3.15 (not nice) or temporarily requiring some temporary signal to get a dict. If None were intended to be used indefinitely to get the old return, the signal would have to be something else, like passing the dict class. (Yes, a bit ugly.) I believe there is precedent to making an immediate change when the alternative is seen as worse. Part of the trade-off in such a decision would be knowing how common programmatic uses there are (and better, about how many of those would be broken). (There are core devs who have scripts to do such searches.) "Consulting with the security council" should begin with a post to the Python Core Dev discord. (edit: sorry for the mis-click) |
@gpshead, I implemented your suggestion. Do you mind to review it? @terryjreedy, please make yet one look at it. |
Sorry I did not get back to this. Looks like the best we could do under the costraints. |
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.
thanks for doing this!
…H-111404) * When called with a single argument to get a value, it allow to omit the minus prefix. * It can be called with keyword arguments to set attributes. * w.wm_attributes(return_python_dict=True) returns a dict instead of a tuple (it will be the default in future). * Setting wantobjects to 0 no longer affects the result.
📚 Documentation preview 📚: https://cpython-previews--111404.org.readthedocs.build/