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

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