I tried all sort of options but no success in implement simple scrollbar for two or more listboxes. Following is my code giving error while scrolling. I hope you guys are helping me…
scrollbar .scroll -orient v
pack .scroll -side left -fill y
listbox .lis1
pack .lis1 -side left
listbox .lis2
pack .lis2 -side left
for {set x 0} {$x < 100} {incr x} {
.lis1 insert end $x
.lis2 insert end $x
}
.lis1 configure -yscrollcommand [list .scroll set]
.lis2 configure -yscrollcommand [list .scroll set]
.scroll configure -command ".lis1 yview .lis2 yview ";
thanking you.
There are a number of examples on the Tcler’s wiki, but the core principle is to use a procedure to ensure that the scrolling protocol is synchronized between the widgets. Here’s an example based off that wiki page:
It’s worth noting that you can also plug any other scrollable widget into this scheme; everything in Tk scrolls the same way (except with
-xscrollcommandandxviewfor horizontal scrolling, together with a change of scrollbar orientation). Furthermore, the connectors here, unlike the ones on the wiki page, can be used with multiple groups of scrolled widgets at once; the knowledge of what is scrolled together is stored in the-commandoption of the scrollbar (first argument tosynchScrollcallback).[EDIT]: For 8.4 and before, you need slightly different connector procedures:
Everything else will be the same.