Python Tkinter Anchors


Anchors are used to defining where text is positioned relative to a reference point.

Here is a list of possible constants, which can be used for the Anchor attribute.

  • NW
  • N
  • NE
  • W
  • E
  • SW
  • S
  • SE

For example, if you use CENTER as a text anchor, the text will be centered horizontally and vertically around the reference point.

Anchor NW will position the text so that the reference point coincides with the northwest (top left) corner of the box containing the text.

Anchor 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.

If you create a small widget inside a large frame and use the anchor=SE option, the widget will be placed in the bottom right corner of the frame. If you used anchor=N instead, the widget would be centered along the top edge.


The anchor constants are shown in this diagram -

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.