Multiple selections in Tix Hlist

Discussion in 'Python' started by theoryboy@my-deja.com, May 18, 2005.

  1. Guest

    I'm trying to implement multiple selection functionality in a Tix Hlist
    using a control-click. I've bound control-click to a function that uses
    selection_set to add to the selection, but it doesn't seem to work.
    Only the last clicked item appears selected (highlighted) in the
    display and the return from info_selection only ever contains the last
    2 items, rather than all the items I have control-clicked.

    It's odd, because if I set up the list and then set up a breakpoint, I
    can set multiple selections at the debug command line and it works as I
    would expect.

    My other problem is that there is no "selection_unset()" method, for
    using a control click to individually unselect one item from the list.
    There is only selection_clear(), which clears all selections. Am I
    missing something?

    Below is some sample code:

    #!/usr/bin/python

    from Tix import *

    class ControlClickTest:

    def __init__(self, master):
    root = master
    modalPane = Toplevel(root)
    self.listBox = HList(modalPane)
    self.listBox.pack()
    items = ['1','2','4','6','8']
    for item in items:
    self.listBox.add(item, itemtype=TEXT, text=item)
    self.listBox.bind('<Control-Button-1>', self.ctrlClick)
    root.wait_window(modalPane)

    def ctrlClick(self, event):
    print "control click!"
    index = self.listBox.nearest(event.y)
    self.listBox.selection_set(index)
    print self.listBox.info_selection()

    if __name__ == "__main__":
    ControlClickTest(Tk())


    Any ideas?

    Peter
     
    , May 18, 2005
    #1
    1. Advertising

  2. To answer my own question:

    HList(selectmode="extended")

    does all the work for you.

    Peter
     
    Peter Saffrey, May 23, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bill yeager

    multiple listbox selections

    bill yeager, Aug 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    450
    bill yeager
    Aug 12, 2003
  2. =?Utf-8?B?QWRpcw==?=
    Replies:
    0
    Views:
    384
    =?Utf-8?B?QWRpcw==?=
    Oct 19, 2004
  3. Replies:
    0
    Views:
    342
  4. Tim N. van der Leeuw

    Tix Tree / HList widget?

    Tim N. van der Leeuw, Jun 19, 2006, in forum: Python
    Replies:
    0
    Views:
    617
    Tim N. van der Leeuw
    Jun 19, 2006
  5. ivan

    Tix.HList - Move Cursor

    ivan, Apr 29, 2008, in forum: Python
    Replies:
    0
    Views:
    357
Loading...

Share This Page