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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollbar canvas not working

Status
Not open for further replies.

godatguitar

Programmer
May 8, 2003
33
GB
Hi

I have a scrollbar that is attached to the canvas, and the scrollbar resizes itself correctly to the size of canvas, and the scrollregion, and the bar itself scrolls nicely. However, it does not scroll the canvas with it. The canvas does not move at all. I am completely stuck, as i am new to this, and i have another thread here about the same problem, i was helped but to no avail. It should work, as they are attached, and the bar is told to control, via command, the canvas (.top23.can24 yview) and the canvas is told that the yscrollcommand is .top23.scr23 set, ie the scrollbar (.scr23) controls it.
I am desperate for help, so if anyone knows whats wrong, please reply!
Many thanks
 
Here is a working example:
Code:
  set dx 40
  set dy 16
  set ww [expr {5 * $dx}]
  set hh [expr {5 * $dy}]
  canvas .can -width $ww -height $hh -yscrollcommand {.sb set}
  scrollbar .sb -command {.can yview}
  set y 0
  for {set i 0} {$i < 35} {incr i}   {
    set x 0
    for {set j 0} {$j < 5} {incr j}     {
      .can create text $x $y -anchor nw -tags tag$i-$j -text &quot;$i-$j&quot;
      incr x $dx
    }
    incr y $dy
  }
  pack .can .sb -side left -fill y
  .can config -scrollregion [.can bbox all]

If this can't help you, I suggest you exhibit some piece of code that doesn't work as you expect.

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top