Geometry Management : Grid, Pack

Grid

The grid command 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 grid command can have any of several forms, depending on the option argument. In short, grid is the name given to the thingy that will place your widget where you want it to be placed.

Some Options

-sticky STYLE This option may be used to position (or stretch) the widget within its cell. STYLE is a string that contains zero or more of the characters n, s, e or w. Each letter refers to a side (north, south, east, or west) that the slave will "stick" to. If both n and s (or e and w) are specified, the slave will be stretched to fill the entire height (or width) of its cavity.
-in MASTER The widget will be placed in the MASTER widget.
-ipadx AMOUNT The AMOUNT 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.
-ipady AMOUNT The AMOUNT specifies how much vertical internal padding to leave on each side of the slave(s). Options same as -ipadx
-padx AMOUNT The amount specifies how much horizontal external padding to leave on each side of the slave(s), in screen units. AMOUNT may be a list of two values to specify padding for left and right separately.
-pady AMOUNT The amount specifies how much vertical external padding to leave on the top and bottom of the slave(s), in screen units. Options same as -padx.
-row N Insert the slave so that it occupies the Nth 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 grid, or the first unoccupied row if this is the first slave.
-column N Insert the slave so that it occupies the N'th column in the grid. Options same as -row
-rowspan N Insert the slave so that it occupies N rows in the grid. The default is one row.
-columnspan N Insert the slave so that it occupies N columns in the grid.

 

pack

Pack is also a geometry manager like Grid - but much simpler. You don't have to specify the rows and columns as  you did for grid. This is for you lazybones out there. Just put pack <widget_path> and the widget will be packed. If two widgets are given, the second widgets will be packed below the first(by default). But for more complex arrangements with pack one must use frames.

Some Options

-expand BOOLEAN Specifies whether the slaves should be expanded to consume extra space in their master. Sounds a lot like slaves eating up their masters, don't it? It just means that when the application is resized the widgets will automatically fill the space.
-fill STYLE This will stretch the widget in x direction, y direction or both directions.
-in MASTER Use this if you want to pack your widget in a frame or something like that.
-side SIDE Specifies which side of the master the slave(s) will be packed against. Must be left, right, top, or bottom. Defaults to top.
posted @ 2013-07-28 18:43  greencolor  阅读(292)  评论(0编辑  收藏  举报