Posted to tcl by suchenwi at Fri Oct 19 13:51:59 GMT 2007view raw

  1. proc scrolled_canvas w {
  2. set wp [file root $w] ;# w does not exist yet - hen/egg problem
  3. scrollbar $wp.y -command "$w yview"
  4. grid [canvas $w -xscrollc "$wp.x set" -yscrollc "$wp.y set"] \
  5. $wp.y -sticky ns
  6. grid [scrollbar $wp.x -ori hori -command "$w xview"] -sticky ew
  7. grid $w -sticky news
  8. if {$wp eq ""} {set wp .}
  9. grid columnconfig $wp 0 -weight 1
  10. #grid columnconfig $wp 1 -weight 0
  11. grid rowconfig $wp 0 -weight 1
  12. set w
  13. }
  14.  
  15. pack [panedwindow .pw -sashwidth 3] -fill both -expand 1
  16. set t [frame .pw.t]
  17. set g(canvas) [scrolled_canvas $t.c]
  18.  
  19. set f [frame .pw.f]
  20.  
  21. .pw add $f -width 300
  22. .pw add $t -width 600
  23.  
  24.