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
Refactor dict result handling in Tkinter #66422
Comments
Proposed patch refactors code which converts the result of Tcl call to Python dict. Added new private function _splitdict() which does this in more robust manner. Also this patch fixes a bug in Treeview.heading(). The heading subcommand of ttk::treeview return options dict in which one key surprisingly was not '-' prefixed. % ttk::treeview t Current code unconditionally cuts "s" from the "state" key. >>> from tkinter import ttk
>>> t = ttk.Treeview()
>>> t.heading('#0')
{'anchor': 'center', 'tate': '', 'image': '', 'text': '', 'command': ''} |
The patch expands and fixes buggy ttk._dict_from_tcltuple, renames and moves it to tkinter._splitdict, and replace 4 similar blocks of code in tkinter with calls to _splitdict. Review published. The only substantive comment is about keeping the test, in a new location. Aside from the comments, this is a nice code improvement. |
The patch expands and fixes buggy ttk._dict_from_tcltuple, renames and moves it to tkinter._splitdict There are differences between these functions. tkinter._splitdict calls splitlist on its argument, ttk._dict_from_tcltuple requires argument to be tuple/list. ttk._dict_from_tcltuple calls tclobjs_to_py on the result, tkinter._splitdict left it to the caller. Instead tkinter._splitdict allows you to specify custom function for dict values convertion. Updated patch addresses Terry's comments. Function name is matter of bakeshedding. |
If there are no objections I'll commit the patch soon. |
I made two style comments, one an expansion of a previous comment. I believe all other previous comments were handled ok. |
Thank you Terry. Fixed style in two methods, added a summary to Treeview.set() docstring and changed returns/sets to return/set. But I disagree with other suggestions. Return value of 3-arg call is insignificant implementation detail. In any case these changes are irrelevant to this issue. |
looks good to commit. |
New changeset 7b0fdc1e917a by Serhiy Storchaka in branch '2.7': New changeset f89995a4ec11 by Serhiy Storchaka in branch '3.4': New changeset 11cf18ec1900 by Serhiy Storchaka in branch 'default': |
Thank you Terry for your review. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: