Posted to tcl by emiliano at Thu Feb 05 21:06:35 GMT 2009view raw

  1. package require Tk 8.5
  2. package require Tcl 8.5
  3.  
  4. canvas .c -xscrollcommand {.sx set} -yscrollcommand {.sy set}\
  5. -bg white -borderwidth 0 -highlightthickness 0
  6. ttk::scrollbar .sx -command {.c xview} -orient horizontal
  7. ttk::scrollbar .sy -command {.c yview} -orient vertical
  8. grid .c .sy -sticky news
  9. grid .sx -sticky news
  10. grid columnconfigure . 0 -weight 1
  11. grid rowconfigure . 0 -weight 1
  12.  
  13. set w [expr {int([winfo screenwidth .]*0.85)}]
  14. set h [expr {int([winfo screenheight .]*0.85)}]
  15.  
  16. set img [image create photo -width $w -height $h]
  17. $img put black -to 0 0 $w $h
  18. .c create image {0 0} -image $img -anchor nw
  19.  
  20. .c configure -scrollregion [.c bbox all]
  21.  
  22. #(8<)============================================================(8<)
  23.  
  24. This code shows the same behaviour as the previous post and is smaller
  25.  

Comments

Posted by emiliano at Thu Feb 05 21:13:34 GMT 2009 [text] [code]

forgot to add: resize the window so that it occupies the full width of the screen and scroll the canvas vertically