Next / Previous / Contents / TCC Help System / NM Tech homepage

3.1. The .grid() method

To display a widget w on your application screen:

    w.grid(option, ...)

This method registers a widget w with the grid geometry manager—if you don't do this, the widget will exist internally, but it will not be visible on the screen.

Here are the options to the .grid() geometry management method:

columnThe column number where you want the widget gridded, counting from zero. The default value is zero.
columnspanNormally a widget occupies only one cell in the grid. However, you can grab multiple cells of a row and merge them into one larger cell by setting the columnspan option to the number of cells. For example, w.grid(row=0, column=2, columnspan=3) would place widget w in a cell that spans columns 2, 3, and 4 of row 0.
ipadxInternal x padding. This dimension is added inside the widget inside its left and right sides.
ipadyInternal y padding. This dimension is added inside the widget inside its top and bottom borders.
padxExternal x padding. This dimension is added to the left and right outside the widget.
padyExternal y padding. This dimension is added above and below the widget.
rowThe row number into which you want to insert the widget, counting from 0. The default is the next higher-numbered unoccupied row.
rowspanNormally a widget occupies only one cell in the grid. You can grab multiple adjacent cells of a column, however, by setting the rowspan option to the number of cells to grab. This option can be used in combination with the columnspan option to grab a block of cells. For example, w.grid(row=3, column=2, rowspan=4, columnspan=5) would place widget w in an area formed by merging 20 cells, with row numbers 3–6 and column numbers 2–6.
stickyThis option determines how to distribute any extra space within the cell that is not taken up by the widget at its natural size. See below.