Hi,
I am new to Tcl/Tk programming and I must be missing something very simple here. I am trying to create two listboxes and the entries in second box is controlled by the item selected in first list box. I managed to get this working by bind <<ListboxSelect>> commands. Issue is, when I select the items in second listbox (X Y Z or P Q R ) listbox1 item is not highlighted any more (blue background). Is it possible to highlight the selected items in both boxes same time? (for example "1" in listbox 1 and "Y" in listbox2 ).
Here is my simple code and I am using Tcl8.4.
Thanks in advance for all your help.
###
set list1val "1 2"
scrollbar .s1 -command ".list1 yview"
listbox .list1 -selectmode "single" -yscroll ".s1 set" -listvariable list1val
scrollbar .s2 -command ".list2 yview"
listbox .list2 -selectmode "single" -yscroll ".s2 set" -listvariable list2val
bind .list1 <<ListboxSelect>> { setlist_second [.list1 curselection] }
grid .list1 -row 0 -column 0 -sticky news
grid .s1 -row 0 -column 1 -sticky news
grid .list2 -row 0 -column 2 -sticky news
grid .s2 -row 0 -column 3 -sticky news
proc setlist_second { SelIndex } {
if { $SelIndex == 0} {
variable list2val "X Y Z"
} else {
variable list2val "P Q R"
}
}
###
--Nikhil
I am new to Tcl/Tk programming and I must be missing something very simple here. I am trying to create two listboxes and the entries in second box is controlled by the item selected in first list box. I managed to get this working by bind <<ListboxSelect>> commands. Issue is, when I select the items in second listbox (X Y Z or P Q R ) listbox1 item is not highlighted any more (blue background). Is it possible to highlight the selected items in both boxes same time? (for example "1" in listbox 1 and "Y" in listbox2 ).
Here is my simple code and I am using Tcl8.4.
Thanks in advance for all your help.
###
set list1val "1 2"
scrollbar .s1 -command ".list1 yview"
listbox .list1 -selectmode "single" -yscroll ".s1 set" -listvariable list1val
scrollbar .s2 -command ".list2 yview"
listbox .list2 -selectmode "single" -yscroll ".s2 set" -listvariable list2val
bind .list1 <<ListboxSelect>> { setlist_second [.list1 curselection] }
grid .list1 -row 0 -column 0 -sticky news
grid .s1 -row 0 -column 1 -sticky news
grid .list2 -row 0 -column 2 -sticky news
grid .s2 -row 0 -column 3 -sticky news
proc setlist_second { SelIndex } {
if { $SelIndex == 0} {
variable list2val "X Y Z"
} else {
variable list2val "P Q R"
}
}
###
--Nikhil