TIP 21: Asymmetric Padding in the Pack and Grid Geometry Managers

Login
Author:         D. Richard Hipp <[email protected]>
State:          Final
Type:           Project
Vote:           Done
Created:        14-Jan-2001
Post-History:   
Tcl-Version:    8.4
Implementation-URL: http://www.hwaci.com/sw/asym_pad_patch_2.txt

Abstract

Proposes modifying the pack and grid geometry managers to support asymmetric padding.

Rationale

The pack and grid geometry managers allow for adding extra space to the left and right of a widget using the -padx option, and above and below the widget using -pady. But there is currently no way to add different amounts of space on opposite sides of the widget. When a layout requires differing amounts of space on opposite sides of the same widget, the usual solution is to introduce extra frame widgets to act as spacers. But that both complicates the code unnecessarily and obscures the intent of the programmer.

Proposed Enhancement

This TIP proposes to modify the -padx and -pady of both the pack and grid geometry managers as follows: If the argument to -padx or -pady is a screen distance, that distance is added to both sides of the widget. (This is the current behavior.) If the argument is a list of two screen distances, then the first screen distance is the extra space to add to the left or top and the second screen distance is the extra space to add to the right or bottom.

The changes to -padx and -pady occur in pack only if the pack geometry manager is used according to the new syntax. The older deprecated syntax (that dates from Tk3.3) will not support asymmetric padding.

Copyright

This document has been placed in the public domain.

Patch

Patches to implement asymmetric padding in the pack and grid geometry managers, as described above, are available at http://www.hwaci.com/sw/asym\_pad\_patch\_2.txt