package require Tk pack [button .b -text "Porco Dio" \ -command {.b configure \ -text "Sempre sia porcato" \ -command exit}] pack [canvas .c -width 300 -height 300] foreach {x y} {0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2} { .c create rectangle \ [expr $x*100] [expr $y*100] [expr ($x+1)*100] [expr ($y+1)*100] \ -tags _${x}${y} -outline {} } proc x {} { set rand {} foreach max {3 3 256 256 256} { lappend rand [expr int(rand()*$max)] } lassign $rand x y r g b .c itemconfigure _${x}${y} -fill [format #%02x%02x%02x $r $g $b] after 50 x } x