Skip to content

Multiple item arguments for selection operations #71506

Closed

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on Jun 14, 2016

      @serhiy-storchaka
      MemberAuthor

      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.

    2. terryjreedy commented on Jun 15, 2016

      @terryjreedy
      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()
      ()
    3. serhiy-storchaka commented on Jun 15, 2016

      @serhiy-storchaka
      MemberAuthor

      I'm puzzled too.

    4. serhiy-storchaka commented on Jun 15, 2016

      @serhiy-storchaka
      MemberAuthor

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

    5. terryjreedy commented on Jun 15, 2016

      @terryjreedy
      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.

    6. serhiy-storchaka commented on Jun 15, 2016

      @serhiy-storchaka
      MemberAuthor

      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.

    7. serhiy-storchaka commented on Jun 18, 2016

      @serhiy-storchaka
      MemberAuthor

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

    8. terryjreedy commented on Jun 19, 2016

      @terryjreedy
      Member

      Then don't. Better to do nothing until sure than to deprecate and then undeprecate. Thinking about it, I am not sure either.

    9. python-dev commented on Jun 19, 2016

      python-devmannequin
      Mannequin

      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

    10. serhiy-storchaka commented on Jun 19, 2016

      @serhiy-storchaka
      MemberAuthor

      Thank you for your review Terry.

    11. serhiy-storchaka commented on Sep 24, 2017

      @serhiy-storchaka
      MemberAuthor

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

    12. serhiy-storchaka commented on Sep 24, 2017

      @serhiy-storchaka
      MemberAuthor

      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

    13. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions