Posted to tcl by kbk at Thu Oct 29 02:53:25 GMT 2009view pretty

set i 0
set buttonList {}
foreach color {red orange yellow green blue indigo violet} {
    button .b[incr i] -text $color -command [list doSomething $color]
    lappend buttonList .b$i 
    # you need to put the buttons in the table
}
# $buttonList is now the list of buttons that the loop created