By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,905 Members | 1,585 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,905 IT Pros & Developers. It's quick & easy.

Multiple selections in Tix Hlist

P: n/a
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

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
To answer my own question:

HList(selectmode="extended")

does all the work for you.

Peter

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.