A grid of buttons, done with grid.
# http://wiki.tcl.tk/39580 # gridDemo-grid1.tcl package require Tk global Prg set Prg(Title) "Grid-Demo_11" set Prg(Version) "v0.01" set Prg(Date) "2014-03-15" set Prg(Author) "Hans-Joachim Gurt" set Prg(Contact) [string map -nocase {: @ ! .} gurt:gmx!de] set Prg(About) "Grid-Demo - Grid" set Prg(Msg) "using grid, with labels and buttons" proc start {} { set ::Prg(Msg) "Starting..." after 1000 { .b11 invoke } ;# Sorry, no animated button-press here... after 1500 { .b22 invoke } after 2000 { .b33 invoke } } proc ButtonProc { b } { set ::Prg(Msg) "Button pressed: $b" } #: Main wm title . "$Prg(Title) $Prg(Version)" puts "$Prg(Title) $Prg(Version)" label .lb_1 -text "GridDemo" -width 12 -bg white -pady 10 label .lb_2 -textvariable Prg(Msg) -width 30 -bg grey -pady 10 option add *Button.width 4 option add *Button.height 2 # button .b11 -text "11" -command { ButtonProc "11" } for {set i 11} {$i<=14} {incr i} { button .b$i -text "$i" -command "ButtonProc $i" } for {set r 2} {$r<=4} {incr r} { for {set c 1} {$c<=4} {incr c} { button .b$r$c -text "$r$c" -command "ButtonProc $r$c" } } option add *Button.width 7 option add *Button.height 1 button .bt_start -text "Start" -command { start } button .bt_quit -text "Quit" -command { exit } grid .lb_1 grid .b11 .b12 .b13 .b14 -sticky nsew grid .b21 .b22 .b23 .b24 -sticky nsew grid .b31 .b32 .b33 .b34 -sticky nsew grid .b41 .b42 .b43 .b44 -sticky nsew grid .lb_2 grid .bt_start - .bt_quit grid configure .lb_1 -columnspan 4 -padx 4 grid configure .lb_2 -columnspan 4 -padx 4 grid configure .bt_start -columnspan 2 -padx 4 grid configure .bt_quit -columnspan 2 -padx 4 #.Compared to the version with pack, this looks simpler (no need to define frame & pack),
but now we need more "grid configure" to tweak the layout.Also, putting in the colors from that version would require some extra work.