Skip to content
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

Closed
serhiy-storchaka opened this issue Jun 14, 2016 · 12 comments
Closed

Multiple item arguments for selection operations #71506

serhiy-storchaka opened this issue Jun 14, 2016 · 12 comments
Assignees
Labels
stdlib Python modules in the Lib dir topic-tkinter type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 27319
Nosy @terryjreedy, @serhiy-storchaka
PRs
  • bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). #3667
  • [3.6] bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). (GH-3667) #3719
  • Files
  • treeview_selection_items.patch
  • 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:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-06-19.21:07:37.629>
    created_at = <Date 2016-06-14.17:41:00.049>
    labels = ['expert-tkinter', 'type-feature', 'library']
    title = 'Multiple item arguments for selection operations'
    updated_at = <Date 2017-09-24.12:03:50.735>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-09-24.12:03:50.735>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-06-19.21:07:37.629>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'Tkinter']
    creation = <Date 2016-06-14.17:41:00.049>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['43390']
    hgrepos = []
    issue_num = 27319
    keywords = ['patch']
    message_count = 12.0
    messages = ['268574', '268594', '268600', '268602', '268603', '268618', '268789', '268835', '268869', '268870', '302850', '302854']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'python-dev', 'serhiy.storchaka']
    pr_nums = ['3667', '3719']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27319'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir topic-tkinter type-feature A feature request or enhancement labels Jun 14, 2016
    @terryjreedy
    Copy link
    Member

    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()
    ()

    @serhiy-storchaka
    Copy link
    Member Author

    I'm puzzled too.

    @serhiy-storchaka
    Copy link
    Member Author

    splitlist() always returns a tuple. How selection() ca return a string?!

    @terryjreedy
    Copy link
    Member

    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
    Copy link
    Member Author

    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 serhiy-storchaka self-assigned this Jun 15, 2016
    @serhiy-storchaka
    Copy link
    Member Author

    I'm not sure that passing multiple items as a tuple should be deprecated.

    @terryjreedy
    Copy link
    Member

    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
    Copy link
    Mannequin

    python-dev mannequin commented 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
    Copy link
    Member Author

    Thank you for your review Terry.

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 2fad102 by Serhiy Storchaka in branch 'master':
    bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). (bpo-3667)
    2fad102

    @serhiy-storchaka
    Copy link
    Member Author

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir topic-tkinter type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants