#Define title and matrix size wm title . "Entry Matrix using grid command" set rows 4 set columns 4 #Using loop to create entry cells and then packing them using grid command for {set i 1} {$i <= $rows} {incr i} { for {set j 1} {$j <= $columns} {incr j} { set m($i$j) "label$i$j" entry .e$i$j -width 12 -justify center -textvariable m($i$j) grid .e$i$j -row [expr $i-1] -column [expr $j-1] } } button .print -text Print -command printout button .exit -text Exit -command exit grid .print .exit -columnspan 2 proc printout {} { global m rows columns for {set i 1} {$i <= $rows} {incr i} { for {set j 1} {$j <= $columns} {incr j} { puts $m($i$j) } } } #Note: the advantage of grid command is to align elements into row and/or column style. #(P.Pongcharoen 2/2001).