For this beginner python Tkinter video we are adding unto the topic of styling in labels. The following topics are going to be discussed:
1 - Precedence in styling Tkinter Labels
Although we can always use the Style class in order to create styling configurations, some labels need to drift away from the general template applied on the GUI. This is where the configure method is important. This method will allow you to have a specific style applied to the widget that you are using. It will also override the styling configuration from the Style class if you decide to switch the template in configure.
2 - Width in Tkinter Labels
Width will allow you to change the size of your label only in the horizontal direction. Width is relative the font size you give to your label. The units of width are simply text units and not pixels. So even though two labels have the same width, the font size is what truly determines the final size of the label.
3- Wraplength in Tkinter Labels
Labels usually do not have much text on them. But if you decide to have one you can always use the wraplength property to set a line length before your text goes into another line. The units for wraplength are in pixels and it determines how long a line of text should be before moving unto the next one.
4- Anchor in Tkinter Labels
Anchor is noticeable if your label becomes larger. It follows the same directions as sticky:
North (top) : your text will appear at the top of your label
Center: your text will appear in the middle of your label
South (bottom): your text will appear at the bottom
West (left): your text will appear on the left.
East (right): your text will appear on the right.
You also have the 4 corners available by simply anchoring to NW, NE, SW, and SE.
5 - Justify in Tkinter Labels
Justify is a very common functionality. It will set your text to start writing a new line from the center, left or right just like in microsoft word or google docs.
Leave a like, comment and subscribe !
On this page of the site you can watch the video online Python Tkinter - Creating Labels and Styling - Part 2 with a duration of hours minute second in good quality, which was uploaded by the user Thinking Through Code 21 May 2022, share the link with friends and acquaintances, this video has already been watched 1,906 times on youtube and it was liked by 66 viewers. Enjoy your viewing!