-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Multiple item arguments for selection operations #71506
Comments
For now methods selection_set(), selection_add(), selection_remove() and selection_toggle() of ttk.TreeView take the single argument that should be either the single item id or a tuple or list of item ids. In contrary methods delete() and detach() take item ids as a variable number of arguments. The latter interface looks more pythonic, more consistent and errorproof. Proposed patch (based on Terry's suggestion in bpo-26386) makes selection methods accepting a variable number of arguments. For compatibility with older versions a tuple or list of item ids can be specified as a single argument, but this interface is deprecated (with long deprecation period). In addition deprecated other weird interface. For now the selection() method can take a subcommand name and items, for example tv.selection('add', 'ITEM1'). If the first argument is None, arguments are ignored, tv.selection(None, 'spam') equals to tv.selection(). Now all this is deprecated and will be TypeError in 3.7. |
Code looks good, just a couple of comments. But I am puzzled by string return before patch
>>> tv.selection()
''
versus tuple return after patch (which seems correct).
>>> tv.selection()
() |
I'm puzzled too. |
splitlist() always returns a tuple. How selection() ca return a string?! |
I reverted the patch, restarted IDLE, and now I get () as I should. Lets forget about it. Apply or ignore comments as you wish. |
I was puzzled because on one of my machines selection() returned ''. But after updating the workspace the problem is gone. This is just a consequence of the bpo-26386 patch. |
I'm not sure that passing multiple items as a tuple should be deprecated. |
Then don't. Better to do nothing until sure than to deprecate and then undeprecate. Thinking about it, I am not sure either. |
New changeset 7b9ad68db14e by Serhiy Storchaka in branch 'default': |
Thank you for your review Terry. |
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: