This is an unofficial mirror of Tkinter reference documentation (based on Python 2.7 and Tk 8.5) created by the late John Shipman.
It was last updated in 2013 and is unmaintained. [More info]
The Tkinter module defines a number of anchor constants that you can use to control where items are positioned relative to their context. For example, anchors can specify where a widget is located inside a frame when the frame is bigger than the widget.
These constants are given as compass points, where north is up and west is to the left. We apologize to our Southern Hemisphere readers for this Northern Hemisphere chauvinism.
The anchor constants are shown in this diagram:
For example, if you create a small widget inside a large
frame and use the
anchor=tk.SE option, the
widget will be placed in the bottom right corner of the
frame. If you used
anchor=tk.N instead, the
widget would be centered along the top edge.
Anchors are also used to define where text is positioned
relative to a reference point. For example, if you use
tk.CENTER as a text anchor, the text will be
centered horizontally and vertically around the reference
tk.NW will position the text
so that the reference point coincides with the northwest
(top left) corner of the box containing the text. Anchor
tk.W will center the text vertically around
the reference point, with the left edge of the text box
passing through that point, and so on.