Monday, September 7, 2020

Python Tkinter Anchors



Hello dear readers! welcome back another section of my tutorial on Python. In this tutorial post, we are going to be discussing about the Python Tkinter Anchors.

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

Below is the list of possible constants, which can be made use of for anchor attributes -

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

RECOMMENDED: Python Tkinter Fonts

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

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

Anchor W is going to 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. But if you eventually made use of anchor=N instead, the widget is going to be centered along the top edge.

Example

The anchor constants are shown in the diagram below -


RECOMMENDED: Python Tkinter Colors

Alright guys! This is where we are rounding up for this tutorial post. In my next tutorial, we are going to be discussing about the Python Tkinter Relief Styles.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.
Share:

0 comments:

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.