You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiple item arguments for selection operations #71506
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.
Activity
serhiy-storchaka commentedon Jun 14, 2016
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.
terryjreedy commentedon Jun 15, 2016
Code looks good, just a couple of comments.
serhiy-storchaka commentedon Jun 15, 2016
I'm puzzled too.
serhiy-storchaka commentedon Jun 15, 2016
splitlist() always returns a tuple. How selection() ca return a string?!
terryjreedy commentedon Jun 15, 2016
I reverted the patch, restarted IDLE, and now I get () as I should. Lets forget about it. Apply or ignore comments as you wish.
serhiy-storchaka commentedon Jun 15, 2016
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.
serhiy-storchaka commentedon Jun 18, 2016
I'm not sure that passing multiple items as a tuple should be deprecated.
terryjreedy commentedon Jun 19, 2016
Then don't. Better to do nothing until sure than to deprecate and then undeprecate. Thinking about it, I am not sure either.
python-dev commentedon Jun 19, 2016
New changeset 7b9ad68db14e by Serhiy Storchaka in branch 'default':
Issue bpo-27319: Methods selection_set(), selection_add(), selection_remove()
https://hg.python.org/cpython/rev/7b9ad68db14e
serhiy-storchaka commentedon Jun 19, 2016
Thank you for your review Terry.
serhiy-storchaka commentedon Sep 24, 2017
New changeset 2fad102 by Serhiy Storchaka in branch 'master':
bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). (bpo-3667)
2fad102
serhiy-storchaka commentedon Sep 24, 2017
New changeset e31eca4 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). (GH-3667) (bpo-3719)
e31eca4