source: trunk/kitgen/8.x/blt/scroll_canvas.tcl@ 175

Last change on this file since 175 was 175, checked in by demin, 12 years ago

initial commit

File size: 701 bytes
Line 
1# scroll_canvas.tcl --
2# Experiment with scrolling canvas items selectively
3#
4
5canvas .c -width 400 -height 200
6scrollbar .y -command scrollc
7
8grid .c .y -sticky news
9
10.c create text 200 10 -text "Title"
11.c lower [.c create rectangle 0 0 400 30 -fill white -outline {} ]
12
13.c lower [.c create text 10 50 -text "Item" -anchor w -tag Move]
14.c lower [.c create polygon 80 50 140 50 140 350 -fill green -tag Move]
15
16# Set the parameters for the scrollbar
17.y set 0.0 0.5
18set currentPos 0.0
19
20proc scrollc {operation number {unit ""}} {
21 # Ignore scroll operation
22 if { $operation == "moveto" } {
23 set dely [expr {400*($::currentPos-$number)}]
24 set ::currentPos $number
25 .c move Move 0 $dely
26 }
27}
Note: See TracBrowser for help on using the repository browser.