1package provide gridbox 1.0 2 3namespace eval gridbox { 4 variable GRIDDATA ; array set GRIDDATA {} 5 6 proc create { widget args } { 7 variable GRIDDATA 8 9 set a_args(-data) "" 10 set a_args(-param) "" 11 set a_args(-col) 1 12 set a_args(-row) 2 13 array set a_args $args 14 15 set frame [frame $widget] 16 set widget [eval {canvas $frame.gridbox} $a_args(-param) \ 17 -yscrollcommand {[list $frame.yscroll set]}] 18 scrollbar $frame.yscroll -orient vertical -command [list $widget yview] 19 20 grid $widget $frame.yscroll -sticky news 21 grid rowconfigure $frame 0 -weight 1 22 grid columnconfigure $frame 0 -weight 1 23 24 set GRIDDATA($widget,col) $a_args(-col) 25 set GRIDDATA($widget,row) $a_args(-row) 26 27 fill $widget $a_args(-data) 28 29 return $widget 30 } ;# proc create 31 32 proc fill { widget data } { 33 variable GRIDDATA 34 35 set f [frame $widget.f ] 36 $widget create window 0 0 -anchor nw -window $f 37 38 for {set y 1} {$y <= $GRIDDATA($widget,col)} {incr y} { 39 for {set x 1} {$x <= $GRIDDATA($widget,row)} {incr x} { 40 set entr [entry $f.entry$x:$y] 41 grid $entr -sticky we -row [expr $y - 1] -col [expr $x - 1] 42 gui::msgDebug "$entr || ($x, $y)" 43 } ;# for x 44 } ;# for y 45 46 set child $f.entry1:1 47 #tkwait visibility $child 48 set bbox [grid bbox $f 0 0] 49 set incr [lindex $bbox 3] 50 set width [winfo reqwidth $f] 51 set height [winfo reqheight $f] 52 $widget config -scrollregion "0 0 $width $height" 53 $widget config -yscrollincrement $incr 54# $widget config -width $width -height $height 55 } ;# proc fill 56} ;# namespace gridbox 57 58