TIP #147: Make Grid's Column/Row Configure Easier

Title:Make Grid's Column/Row Configure Easier
Version:$Revision: 1.5 $
Author:Peter Spjuth <peter dot spjuth at space dot se>
Created:Tuesday, 05 August 2003


This TIP proposes to add an alternative way to state which columns/rows in a grid are affected by an column/rowconfigure command.


Usually when doing a grid layout I tend to think in terms of what I want to do with a particular widget. For example a canvas or a frame that I want to expand within a resized window. Currently I need to translate that intention into a column and a row number to pass to column/rowconfigure. A more direct approach would be to pass the widget name directly to column/rowconfigure.

Another situation is when all columns should be affected. Here I currently need to list them all {0 1 2 3 4 5}. Allowing an "all" keyword makes it easier and the code becomes more maintainable since you can add/remove columns without updating the list.

What should be done when columnspan is greater than 1?

There are three obvious possibilities: affect all, affect the first and affect the last. Any of these may be wanted by a programmer at one time or another so whatever is chosen, someone will be annoyed with it. Affecting all seems most logical.

See also http://sf.net/tracker/?func=detail&aid=659218&group_id=12997&atid=362997


Anywhere column is used below, the same applies to row too.

In the index argument to grid columnconfigure, widget names and the keyword "all" is recognised besides the normal integers.

When a widget name is used, it must be currently managed by the given master. The columns currently occupied by the widget are affected by the command.

When the keyword "all" is used, all columns currently occupied by widgets in master are affected by the command.

Note: "Currently occupied" means at the time of the invocation of the grid columnconfigure command. The grid does not try to trace if a widget is moved in the grid or if more widgets are added.


canvas .c
scrollbar .sbx -orient horizontal
scrollbar .sby -orient vertical
grid .c .sby -sticky news
grid .sbx    -sticky we
grid columnconfigure . .c -weight 1
grid rowconfigure    . .c -weight 1

button .b1 -text a
button .b2 -text b
button .b3 -text example
button .b4 -text xyzzy
grid .b1 .b2 .b3 .b4 -sticky news
grid columnconfigure . all -uniform a -weight 1

Other Possibilities

One possibility that is not proposed in this TIP is to also recognise the end-style indexing that indices in Tcl support (through TclGetIntForIndex().)

Comment: "Personally, I think that end-index handling will be quite tricky since it would require knowing what the *user* thinks is the last column."

Reference Implementation

Not implemented yet.


This document has been placed in the public domain.

Powered by Tcl[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows