#!/proj/tcl/install/5.x-sparc/bin/wish4.1b2 # # An very simple example of a table implemented on top of a grid system. # # The routine to set up a simple grid. proc grid_table {parent {numcols 1} {numrows 1} {color blue}} { if {$parent == "."} { set base "" } else { set base $parent } for {set i 0} {$i <= [expr $numcols+1]} {incr i} { frame $base.fc${i} -width 1 -bg $color grid $base.fc${i} -column [expr $i*2] -row 0 \ -rowspan [expr $numrows*2 +3] -sticky {ns} grid columnconfig $parent [expr $i*2] -minsize 1 -weight 0 } for {set j 0} {$j <= [expr $numrows+1]} {incr j} { frame $base.fr${j} -height 1 -bg $color grid $base.fr${j} -column 0 -row [expr $j*2] \ -columnspan [expr $numcols*2+3] -sticky {ew} grid rowconfig $parent [expr $j*2] -minsize 1 -weight 0 } proc realx {x} { return [expr $x*2 +1] } proc realy {y} { return [expr $y*2 +1] } proc realspan {s} { return [expr $s*2 -1] } for {set i 0} {$i <= [expr $numcols]} {incr i} { grid columnconfig $parent [realx $i] -minsize 10 -weight 1 } for {set j 0} {$j <= [expr $numrows]} {incr j} { grid rowconfig $parent [realy $j] -minsize 10 -weight 1 } } # The meat of the demo. grid_table . 5 5 red button .b -text "Blah!" -command {puts "Got me!"} entry .e grid .b -column [realx 1] -row [realy 3] -columnspan [realspan 3] -sticky {nsew} grid rowconfig . [realy 3] -weight 1 grid .e -column [realx 2] -row [realy 4] \ -sticky {nsew} grid columnconfigure . [realx 2] -weight 1 grid propagate . 1