Posted to tcl by dgp at Wed May 25 16:38:44 GMT 2011view raw

  1.  
  2. set linecount 5000
  3.  
  4. . configure -width 600 -height 300
  5. pack propagate . 0
  6.  
  7. set msg [canvas .msg]
  8.  
  9. set yscroll [scrollbar .yscroll -orient vertical \
  10. -command [list $msg yview]]
  11.  
  12. pack $msg -side left -fill both -expand 1
  13. pack $yscroll -side left -fill y
  14.  
  15. for {set i 0} {$i<$linecount} {incr i} {
  16. append text "$i\n"
  17. }
  18. append text "The end"
  19.  
  20. $msg create text 0 0 -anchor nw -text $text
  21.  
  22. foreach {xmin ymin xmax ymax} [$msg bbox all] break
  23. $msg configure -scrollregion [list $xmin $ymin $xmax $ymax]
  24. $msg configure -yscrollcommand [list $yscroll set] \
  25. -scrollregion [list $xmin $ymin $xmax $ymax]
  26.