Tk Source Code

Artifact [d5c0c7e2]
Login

Artifact d5c0c7e241fae3ade4f168c81e1698d7de3c2f77c2a7c6dacd39044754691d70:

Attachment "nab_canvas.tcl" to ticket [06d8246b] added by marc_culler 2020-06-03 13:00:15.
package require Tk
package require Ttk

ttk::button .b -text push
grid .b -sticky news

for {set x 1} {$x<100} {incr x} {
    canvas .c$x -width 1 -height 2 -bg black
    grid .c$x -sticky news
}

grid columnconfigure . all -weight 1
grid rowconfigure . 1 -weight 1

bind .b <ButtonPress-1> {doColorchange red}
bind .b <ButtonRelease-1> {doColorchange yellow}

proc doColorchange {colour} {
    for {set x 1} {$x<100} {incr x} {
        after $x [list .c$x configure -bg $colour]
     }
}