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

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Peter Spjuth <peter.spjuth@space.se>
State:          Final
Type:           Project
Vote:           Done
Created:        05-Aug-2003
Post-History:   
Tcl-Version:    8.5

Abstract

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

Rationale

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

Specification

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.

Examples

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.

Copyright

This document has been placed in the public domain.

History