Scroll multiple listbox

Posted by ticojohn on 2018-10-10 11:33

After struggling for years to scroll multiple listboxes with a single vertical scroll bar I came upon a really easy solution. Instead of using the vertical scrollbar I used the vertical slider.

I am currently using Visual Tcl, tcl/tk 8.4, on my Debian Jessie (32 bit) machine (I don't like the most recent version of Visual Tcl). The solution is to set a binding for the slider, and in the code get the slider position and use that to set the yview for the listboxes. Here is the Visual Tcl code (binding) for that to work.

      set listIndex [$widget(Scale1) get]
      $widget(Listbox1) yview $listIndex
      $widget(Listbox2) yview $listIndex

For those not using Visual Tcl it should be pretty straightforward to write a procedure to do the same thing.