1mNAME0m
       grid - Geometry manager that arranges widgets in a grid

1mSYNOPSIS0m
       1mgrid 4m22moption24m 4marg24m ?4marg24m 4m...24m?


1mDESCRIPTION0m
       The  1mgrid 22mcommand is used to communicate with the grid geometry manager
       that arranges widgets in rows and columns  inside  of  another  window,
       called  the  geometry  master (or master window).  The 1mgrid 22mcommand can
       have any of several forms, depending on the 4moption24m argument:

       1mgrid 4m22mslave24m ?4mslave24m 4m...24m? ?4moptions24m?
              If the first argument to 1mgrid 22mis suitable  as  the  first  slave
              argument  to  1mgrid  configure22m,  either  a window name (any value
              starting with 1m.22m) or one of the characters 1mx 22mor 1m^ 22m(see the  1mRELA-0m
              1mTIVE  PLACEMENT 22msection below), then the command is processed in
              the same way as 1mgrid configure22m.

       1mgrid bbox 4m22mmaster24m ?4mcolumn24m 4mrow24m? ?4mcolumn224m 4mrow224m?
              With no arguments, the bounding box (in pixels) of the  grid  is
              returned.   The  return value consists of 4 integers.  The first
              two are the pixel offset from the master window (x  then  y)  of
              the top-left corner of the grid, and the second two integers are
              the width and height of the grid, also in pixels.  If  a  single
              4mcolumn24m and 4mrow24m is specified on the command line, then the bound-
              ing box for that cell is returned, where the top  left  cell  is
              numbered from zero.  If both 4mcolumn24m and 4mrow24m arguments are speci-
              fied, then the bounding box spanning the rows and columns  indi-
              cated is returned.

       1mgrid columnconfigure 4m22mmaster24m 4mindex24m ?4m-option24m 4mvalue...24m?
              Query  or  set  the column properties of the 4mindex24m column of the
              geometry  master,  4mmaster24m.   The  valid  options  are  1m-minsize22m,
              1m-weight22m,  1m-uniform  22mand  1m-pad22m.   If one or more options are pro-
              vided, then 4mindex24m may be given as a list of  column  indices  to
              which  the  configuration options will operate on.  The 1m-minsize0m
              option sets the minimum size, in screen units, that will be per-
              mitted  for  this column.  The 1m-weight 22moption (an integer value)
              sets the relative weight for apportioning any extra spaces among
              columns.   A  weight  of  zero (0) indicates the column will not
              deviate from its requested size.  A column whose weight  is  two
              will grow at twice the rate as a column of weight one when extra
              space is allocated to the layout.  The 1m-uniform 22moption,  when  a
              non-empty  value  is  supplied,  places  the column in a 4muniform0m
              4mgroup24m with other columns that have the same value for  1m-uniform22m.
              The  space for columns belonging to a uniform group is allocated
              so that their sizes are always in  strict  proportion  to  their
              1m-weight  22mvalues.   See  1mTHE  GRID  ALGORITHM  22mbelow  for further
              details.  The 1m-pad 22moption specifies the number of  screen  units
              that will be added to the largest window contained completely in
              that column when the grid geometry manager requests a size  from
              the  containing window.  If only an option is specified, with no
              value, the current value of that option is  returned.   If  only
              the  master  window and index is specified, all the current set-
              tings are returned in a list of "-option value" pairs.

       1mgrid configure 4m22mslave24m ?4mslave24m 4m...24m? ?4moptions24m?
              The arguments consist of the names of one or more slave  windows
              followed  by  pairs  of arguments that specify how to manage the
              slaves.  The characters 1m-22m,  1mx 22mand 1m^22m, can be specified instead of
              a  window  name  to  alter  the  default location of a 4mslave24m, as
              described in the 1mRELATIVE PLACEMENT 22msection, below.  The follow-
              ing options are supported:

              1m-column 4m22mn0m
                     Insert  the  slave  so that it occupies the 4mn24mth column in
                     the grid.  Column numbers start with 0.  If  this  option
                     is  not  supplied, then the slave is arranged just to the
                     right of previous slave specified on this call  to  4mgrid24m,
                     or  column "0" if it is the first slave.  For each 1mx 22mthat
                     immediately precedes the 4mslave24m, the  column  position  is
                     incremented by one.  Thus the 1mx 22mrepresents a blank column
                     for this row in the grid.

              1m-columnspan 4m22mn0m
                     Insert the slave so that it occupies  4mn24m  columns  in  the
                     grid.   The default is one column, unless the window name
                     is followed by a 1m-22m,  in  which  case  the  columnspan  is
                     incremented once for each immediately following 1m-22m.

              1m-in 4m22mother0m
                     Insert  the slave(s) in the master window given by 4mother24m.
                     The default is the first slave's parent window.

              1m-ipadx 4m22mamount0m
                     The 4mamount24m specifies how much horizontal internal padding
                     to  leave on each side of the slave(s).  This is space is
                     added inside the slave(s) border.  The 4mamount24m must  be  a
                     valid  screen distance, such as 1m2 22mor 1m.5c22m.  It defaults to
                     0.

              1m-ipady 4m22mamount0m
                     The 4mamount24m specifies how much vertical  internal  padding
                     to  leave  on  the  top and bottom of the slave(s).  This
                     space is added inside the slave(s)  border.   The  4mamount0m
                     defaults to 0.

              1m-padx 4m22mamount0m
                     The 4mamount24m specifies how much horizontal external padding
                     to leave on each side of the slave(s), in  screen  units.
                     4mAmount24m may be a list of two values to specify padding for
                     left and right separately.  The  4mamount24m  defaults  to  0.
                     This space is added outside the slave(s) border.

              1m-pady 4m22mamount0m
                     The  4mamount24m  specifies how much vertical external padding
                     to leave on the top and bottom of the slave(s), in screen
                     units.   4mAmount24m  may  be  a list of two values to specify
                     padding  for  top  and  bottom  separately.   The  4mamount0m
                     defaults  to 0.  This space is added outside the slave(s)
                     border.

              1m-row 4m22mn24m Insert the slave so that it occupies the 4mn24mth row  in  the
                     grid.   Row  numbers start with 0.  If this option is not
                     supplied, then the slave is arranged on the same  row  as
                     the previous slave specified on this call to 1mgrid22m, or the
                     first unoccupied row if this is the first slave.

              1m-rowspan 4m22mn0m
                     Insert the slave so that it occupies 4mn24m rows in the  grid.
                     The  default  is  one row.  If the next 1mgrid 22mcommand con-
                     tains 1m^ 22mcharacters instead of 4mslaves24m that  line  up  with
                     the columns of this 4mslave24m, then the 1mrowspan 22mof this 4mslave0m
                     is extended by one.

              1m-sticky 4m22mstyle0m
                     If a slave's cell is larger  than  its  requested  dimen-
                     sions,  this  option may be used to position (or stretch)
                     the slave within its cell.  4mStyle24m  is a string that  con-
                     tains  zero  or more of the characters 1mn22m, 1ms22m, 1me 22mor 1mw22m.  The
                     string can optionally contains spaces or commas, but they
                     are ignored.  Each letter refers to a side (north, south,
                     east, or west) that the slave will "stick" to.  If both 1mn0m
                     and  1ms  22m(or  1me  22mand  1mw22m)  are specified, the slave will be
                     stretched to fill the entire height  (or  width)  of  its
                     cavity.   The  1msticky  22moption subsumes the combination of
                     1m-anchor 22mand 1m-fill 22mthat is used by 1mpack22m.  The  default  is
                     1m{}22m,  which causes the slave to be centered in its cavity,
                     at its requested size.

              If any of the slaves are already managed by the geometry manager
              then any unspecified options for them retain their previous val-
              ues rather than receiving default values.

       1mgrid forget 4m22mslave24m ?4mslave24m 4m...24m?
              Removes each of the 4mslave24ms from grid for its master  and  unmaps
              their windows.  The slaves will no longer be managed by the grid
              geometry manager.  The configuration options for that window are
              forgotten, so that if the slave is managed once more by the grid
              geometry manager, the initial default settings are used.

       1mgrid info 4m22mslave0m
              Returns a list whose  elements  are  the  current  configuration
              state  of the slave given by 4mslave24m in the same option-value form
              that might be specified to 1mgrid configure22m.  The first  two  ele-
              ments of the list are ``1m-in 4m22mmaster24m'' where 4mmaster24m is the slave's
              master.

       1mgrid location 4m22mmaster24m 4mx24m 4my0m
              Given  4mx24m and 4my24m values in screen units  relative  to  the  master
              window,  the  column  and row number at that 4mx24m and 4my24m location is
              returned.  For locations that are above or to the  left  of  the
              grid, 1m-1 22mis returned.

       1mgrid propagate 4m22mmaster24m ?4mboolean24m?
              If  4mboolean24m has a true boolean value such as 1m1 22mor 1mon 22mthen propa-
              gation is enabled for 4mmaster24m, which must be a window  name  (see
              1mGEOMETRY  PROPAGATION  22mbelow).   If  4mboolean24m has a false boolean
              value then propagation is disabled for  4mmaster24m.   In  either  of
              these  cases an empty string is returned.  If 4mboolean24m is omitted
              then the command returns 1m0 22mor 1m1 22mto indicate whether  propagation
              is  currently  enabled  for  4mmaster24m.   Propagation is enabled by
              default.

       1mgrid rowconfigure 4m22mmaster24m 4mindex24m ?4m-option24m 4mvalue...24m?
              Query or set the row properties of the 4mindex24m row of the geometry
              master,  4mmaster24m.  The valid options are 1m-minsize22m, 1m-weight22m, 1m-uni-0m
              1mform 22mand 1m-pad22m.  If one or more options are provided, then  4mindex0m
              may be given as a list of row indices to which the configuration
              options will operate on.  The 1m-minsize 22moption sets  the  minimum
              size, in screen units, that will be permitted for this row.  The
              1m-weight 22moption (an integer value) sets the relative  weight  for
              apportioning  any extra spaces among rows.  A weight of zero (0)
              indicates the row will not deviate from its requested  size.   A
              row  whose weight is two will grow at twice the rate as a row of
              weight one when extra space is allocated  to  the  layout.   The
              1m-uniform  22moption, when a non-empty value is supplied, places the
              row in a 4muniform24m 4mgroup24m with other rows that have the same  value
              for  1m-uniform22m.   The space for rows belonging to a uniform group
              is allocated so that their sizes are always in strict proportion
              to  their 1m-weight 22mvalues.  See 1mTHE GRID ALGORITHM 22mbelow for fur-
              ther details.  The 1m-pad 22moption specifies the  number  of  screen
              units  that  will  be added to the largest window contained com-
              pletely in that row when the grid geometry  manager  requests  a
              size  from  the  containing window.  If only an option is speci-
              fied, with no  value,  the  current  value  of  that  option  is
              returned.  If only the master window and index is specified, all
              the current settings are returned in a list of  "-option  value"
              pairs.

       1mgrid remove 4m22mslave24m ?4mslave24m 4m...24m?
              Removes  each  of the 4mslave24ms from grid for its master and unmaps
              their windows.  The slaves will no longer be managed by the grid
              geometry  manager.   However, the configuration options for that
              window are remembered, so that if the slave is managed once more
              by  the grid geometry manager, the previous values are retained.

       1mgrid size 4m22mmaster0m
              Returns the size of the grid (in columns then rows) for  4mmaster24m.
              The size is determined either by the 4mslave24m occupying the largest
              row or column, or the largest column  or  row  with  a  1mminsize22m,
              1mweight22m, or 1mpad 22mthat is non-zero.

       1mgrid slaves 4m22mmaster24m ?4m-option24m 4mvalue24m?
              If  no options are supplied, a list of all of the slaves in 4mmas-0m
              4mter24m are returned, most recently manages first.   4mOption24m  can  be
              either  1m-row  22mor 1m-column 22mwhich causes only the slaves in the row
              (or column) specified by 4mvalue24m to be returned.

1mRELATIVE PLACEMENT0m
       The 1mgrid 22mcommand contains a limited set  of  capabilities  that  permit
       layouts to be created without specifying the row and column information
       for each slave.  This  permits  slaves  to  be  rearranged,  added,  or
       removed  without the need to explicitly specify row and column informa-
       tion.  When no column or row information  is  specified  for  a  4mslave24m,
       default  values  are  chosen for 1mcolumn22m, 1mrow22m, 1mcolumnspan 22mand 1mrowspan 22mat
       the time the 4mslave24m is managed. The values are  chosen  based  upon  the
       current layout of the grid, the position of the 4mslave24m relative to other
       4mslave24ms in the same grid command, and the presence of the characters  1m-22m,
       1mx22m, and 1m^ 22min 1mgrid 22mcommand where 4mslave24m names are normally expected.

              1m-      22mThis  increases  the columnspan of the 4mslave24m to the left.
                     Several 1m-22m's in  a  row  will  successively  increase  the
                     columnspan.  A 1m- 22mmay not follow a 1m^ 22mor a 1mx22m, nor may it be
                     the first 4mslave24m argument to 1mgrid configure22m.

              1mx      22mThis leaves an empty column between the 4mslave24m on the left
                     and the 4mslave24m on the right.

              1m^      22mThis  extends  the  1mrowspan 22mof the 4mslave24m above the 1m^22m's in
                     the grid.  The number of 1m^22m's in a row must match the num-
                     ber of columns spanned by the 4mslave24m above it.

1mTHE GRID ALGORITHM0m
       The  grid  geometry manager lays out its slaves in three steps.  In the
       first step, the minimum size needed to fit all of the  slaves  is  com-
       puted,  then  (if  propagation  is turned on), a request is made of the
       master window to become that size.  In the second step,  the  requested
       size  is  compared against the actual size of the master.  If the sizes
       are different, then spaces is added to or taken away from the layout as
       needed.  For the final step, each slave is positioned in its row(s) and
       column(s) based on the setting of its 4msticky24m flag.

       To compute the minimum size of a  layout,  the  grid  geometry  manager
       first  looks at all slaves whose columnspan and rowspan values are one,
       and computes the nominal size of each row or column to  be  either  the
       4mminsize24m for that row or column, or the sum of the 4mpad24mding plus the size
       of the largest slave, whichever is greater.  After  that  the  rows  or
       columns  in  each  uniform  group adapt to each other.  Then the slaves
       whose rowspans or columnspans are greater than one are examined.  If  a
       group  of  rows  or  columns  need  to be increased in size in order to
       accommodate these slaves, then extra space is added to each row or col-
       umn in the group according to its 4mweight24m.  For each group whose weights
       are all zero, the additional space is apportioned equally.

       When multiple rows or columns belong to  a  uniform  group,  the  space
       allocated  to  them is always in proportion to their weights. (A weight
       of zero is considered to be 1.)  In other words, a row or  column  con-
       figured  with  1m-weight  1 -uniform a 22mwill have exactly the same size as
       any other row or column configured with 1m-weight 1 -uniform a22m.  A row or
       column  configured  with  1m-weight 2 -uniform b 22mwill be exactly twice as
       large as one that is configured with 1m-weight 1 -uniform b22m.

       More technically, each row or column in the  group  will  have  a  size
       equal  to  4mk*weight24m  for  some constant 4mk24m.  The constant 4mk24m is chosen so
       that no row or column becomes smaller than its minimum size.  For exam-
       ple,  if all rows or columns in a group have the same weight, then each
       row or column will have the same size as the largest row or  column  in
       the group.

       For  masters  whose size is larger than the requested layout, the addi-
       tional space is apportioned according to the row  and  column  weights.
       If  all of the weights are zero, the layout is centered within its mas-
       ter.  For masters whose size is  smaller  than  the  requested  layout,
       space  is  taken away from columns and rows according to their weights.
       However, once a column or row shrinks to its  minsize,  its  weight  is
       taken to be zero.  If more space needs to be removed from a layout than
       would be permitted, as when all the rows or columns are at their  mini-
       mum sizes, the layout is clipped on the bottom and right.

1mGEOMETRY PROPAGATION0m
       The  grid geometry manager normally computes how large a master must be
       to just exactly meet the needs of its slaves, and it sets the requested
       width and height of the master to these dimensions.  This causes geome-
       try information to propagate up through a window hierarchy  to  a  top-
       level  window so that the entire sub-tree sizes itself to fit the needs
       of the leaf windows.  However, the 1mgrid propagate 22mcommand may  be  used
       to  turn  off  propagation  for one or more masters.  If propagation is
       disabled then grid will not set the requested width and height  of  the
       master window.  This may be useful if, for example, you wish for a mas-
       ter window to have a fixed size that you specify.

1mRESTRICTIONS ON MASTER WINDOWS0m
       The master for each slave  must  either  be  the  slave's  parent  (the
       default)  or  a  descendant of the slave's parent.  This restriction is
       necessary to guarantee that the slave can be placed over  any  part  of
       its master that is visible without danger of the slave being clipped by
       its parent.  In addition, all slaves in one call to 1mgrid 22mmust have  the
       same master.

1mSTACKING ORDER0m
       If  the  master  for  a slave is not its parent then you must make sure
       that the slave is higher in the stacking order than the master.  Other-
       wise  the  master  will  obscure the slave and it will appear as if the
       slave hasn't been managed correctly.  The easiest way to make sure  the
       slave  is  higher than the master is to create the master window first:
       the most recently created window will be highest in the stacking order.

1mCREDITS0m
       The 1mgrid 22mcommand is based on ideas taken from the 4mGridBag24m geometry man-
       ager written by Doug. Stein, and the 1mblt_table 22mgeometry manager,  writ-
       ten by George Howlett.

1mEXAMPLES0m
       A toplevel window containing a text widget and two scrollbars:
              # Make the widgets
              toplevel .t
              text .t.txt -wrap none -xscroll {.t.h set} -yscroll {.t.v set}
              scrollbar .t.v -orient vertical   -command {.t.txt xview}
              scrollbar .t.h -orient horizontal -command {.t.txt xview}
              # Lay them out
              1mgrid 22m.t.txt .t.v -sticky nsew
              1mgrid 22m.t.h        -sticky nsew
              # Tell the text widget to take all the extra room
              1mgrid rowconfigure    22m.t 0 -weight 1
              1mgrid columnconfigure 22m.t 0 -weight 1

       Three widgets of equal width, despite their different "natural" widths:
              button .b -text "Foo"
              entry .e -variable foo
              label .l -text "This is a fairly long piece of text"
              1mgrid 22m.b .e .l -sticky ew
              1mgrid columnconfigure 22m. {0 1 2} -uniform allTheSame


1mSEE ALSO0m
       pack(n), place(n)


1mKEYWORDS0m
