Python Tkinter - Creating Labels and Styling - Part 2

Publicado el: 21 mayo 2022
en el canal de: Thinking Through Code
1,906
66

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 !


En esta página del sitio puede ver el video en línea Python Tkinter - Creating Labels and Styling - Part 2 de Duración hora minuto segunda en buena calidad , que subió el usuario Thinking Through Code 21 mayo 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 1,906 veces y le gustó 66 a los espectadores. Disfruta viendo!