Version 3 of Tk widget sticky discussion

Updated 2004-03-16 17:13:05

Purpose: to provide examples to the beginning Tk programmer of how the -sticky configuration parameter works on the various Tk widgets that support the flag.


For instance:

 frame .addr -background orange
 grid  .addr -sticky we
 entry .addr.addr1 -width 30
 grid  .addr.addr1 -sticky we

The original author's expectation was that the field would be left justified and would expand. - RS would rather expect it to be centered, but fill all available space. Use -justify left for left justification :)

The originator wasn't talking about text within a label or whatever being justified. They were expecting the entry box to hang on the left of frame - me, I don't know why they expected that instead of centered... I certainly expected it centered.

The -sticky argument indicates the developer is specifying on which side(s) of a grid cell a widget should appear. The parms for the -sticky are one of the following:

  • n (north)
  • s (south)
  • e (east)
  • w (west)

or some reasonable combination of these flags.

So, a value of "we" would, in my mind, mean that a widget would be centered along the horizontal axis of the grid cell. A value of "ns" would indicate that a widget would be centered along the vertical axis of the grid cell. A value of "news" would, I presume, attempt to center the widget along both axies.


Category GUI