Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection in multiple listbox widgets

Status
Not open for further replies.

droletbe

Programmer
Jun 28, 2007
1
0
0
CA
I need to create an interface with multiple listbox widgets.

For example, in

Code:
#!/bin/ksh
# exec /bin/ksh \
exec wish "$0" "$@"

listbox .lb1 -selectmode extended
listbox .lb2 -selectmode extended
pack .lb1 .lb2
.lb1 insert end A B C D
.lb2 insert end E F G H

I want the user to be able to select "A" in the first listbox and "F" in the second one.

My problem is that when the user clicks "F" in the second listbox, the "A", or any selection in the first is unselected, and vice-versa

Any idea how to make the selection staying in the other listboxes ?

 
I don't know how to make the listboxes retain the selection. It has to do with focus, I think. What you can do is bind the selection to setting a variable to retrieve it:
Code:
bind .lb1 <Button-1> {set i1 [.lb1 curselection]}
bind .lb2 <Button-1> {set i2 [.lb2 curselection]}
Then use those indices to retrieve the items.

_________________
Bob Rashkin
 
You need to change the -exportselection option value:
Code:
listbox .lb -exportselection 0

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top