Artifact
29b7bd85467f6e3b1cfdea6a4f235351cc31c91b70066518bcbd9d627df409d1:
Attachment "cc_canvas.tcl" to
ticket [06d8246b]
added by
marc_culler
2020-06-03 13:01:45.
package require Tk
package require Ttk
set n 100
set offset 70
set delay 300
set interval 10
ttk::button .b -text push
grid .b -sticky news
for {set x 1} {$x<=$n} {incr x} {
canvas .c$x -width 100 -height 2 -bg black
grid .c$x -sticky news
}
grid columnconfigure . all -weight 1
grid rowconfigure . 1 -weight 1
.b configure -command {
for {set x 1} {$x<=$n} {incr x} {
after [expr "$x*$interval+$delay"] "redcanv .c$x $x"
}
}
proc redcanv {w x} {
global n interval delay
$w configure -bg red
after [expr "$n*$interval+$delay"] "greencanv $w $x"
}
proc greencanv {w x} {
global n offset interval
$w configure -bg [format "#00%02x00" [expr "2*$x"]]
after [expr "($n-$offset)*$interval"] "yellowcanv $w"
}
proc yellowcanv {w} {
$w configure -bg yellow
}