Version 7 of grid

Updated 2003-08-14 18:11:15

http://www.purl.org/tcl/home/man/tcl8.4/TkCmd/grid.htm

Grid is one of several Geometry Managers. Some others are pack and place.

Grid is excellent for many kinds of common GUI forms, because it arranges widgets in nice rows and columns, and handles resizing quite nicely.


A Simple example is a panel with just a few labels and entries.

    package require Tk

    foreach field {Name Address City State Phone} {
        #  Create a couple of widgets
        set l [label .lab$field -text $field]
        set e [entry .ent$field -justify right ]
        #  Assign both to a row in the grid
        grid $l $e -padx 4 -pady 4
        #  Then adjust how they appear
        grid $l -sticky e
        grid $e -sticky ew
    }

    # X-resize is done by the entry column
    grid columnconfigure . 1 -weight 1

    #  Y-resize should be at the bottom...
    set lastrow [lindex [grid size .] 1]
    grid rowconfigure . $lastrow -weight 1

For a little more complex example, see A little spreadsheet.


DKF - The term Grid also refers to the very high end of resource sharing systems over the internet which it is likely that people will be hearing a lot more about in the future, especially in phrases like Grid Services...


Tk syntax help - Arts and crafts of Tcl-Tk programming - Category Command