help with scrolling two listboxes by the single scrollbar 
Author Message
 help with scrolling two listboxes by the single scrollbar

Hello,
 I cannot make 2 listboxes be controlled by a single scrollbar.

 listbox .list1 -yscroll ".s1.set"
 listbox .list2 -yscroll ".s1.set"
 scrollbar .s1 -command {scrollthem yview}

  First, I want listboxes to scroll when I touch scrollbar. So I have to
 do .list1 yview scroll 1 pages (or whatever) and .list2 - same thing.
  I've tried to do it in following manner:

 proc scrollthem {args} {
  global .list1 .list2
  set arg ""
  foreach i $args {
   set arg "$arg $i"
  }
  .list1 $arg # as well as $args
  .list2 $arg # same
 }

 This gives me an error "Bad option "yview scroll 1 pages": must be blah,
 foo, boo, yview".
 Looks like calling .list1 $arg (or $args) treats $arg as a single word.
 How to avoid this?
 (reading fmm didnt help me)

Thanks.



Sat, 13 Apr 2002 03:00:00 GMT  
 help with scrolling two listboxes by the single scrollbar

Quote:

>  I cannot make 2 listboxes be controlled by a single scrollbar.

See the answer in the Tk Usage FAQ:
        http://www.purl.org/net/hobbs/tcl/faqs/tk/

which gives two code solutions.

--
   Jeffrey Hobbs                          The Tcl Guy
   jeffrey.hobbs at scriptics.com         Scriptics Corp.



Sat, 13 Apr 2002 03:00:00 GMT  
 help with scrolling two listboxes by the single scrollbar


Quote:
> Hello,
>  I cannot make 2 listboxes be controlled by a single scrollbar.
[snip]
>  This gives me an error "Bad option "yview scroll 1 pages": must be blah,
>  foo, boo, yview".
>  Looks like calling .list1 $arg (or $args) treats $arg as a single word.

That is correct. $arg (or $args) _is_ a single word. The common solution to
this behavior is to use eval to force a second round of substitution on the
line:

    eval .list1 $arg



Sat, 13 Apr 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Two canvas scrolled simultaneously by the same scrollbar (an UNIQUE scrollbar and TWO or more canvas)

2. Scrolling two listboxes with one scrollbar?

3. A single scrollbar managing two scrollable widgets

4. multiple listboxes (with -selectmode extended) bound to a single scrollbar

5. ListBox / ScrollBar: Fire Event on Scroll

6. Scrolling two different widgets will one scrollbar

7. One Scrollbar for two listboxes??

8. one scrollbar for two listboxes?

9. one scrollbar for two listboxes?

10. Two listboxes, one vert scrollbar

11. Scrolling two listboxes?

12. SYNCHRONIZED SCROLLING, or, ONE SCROLLBAR TO SCROLL 2CanvasesWindows

 

 
Powered by phpBB® Forum Software