Python Tkinter - Creating Labels and Styling - Part 2

Pubblicato il: 21 maggio 2022
sul canale di: 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 !


In questa pagina del sito puoi guardare il video online Python Tkinter - Creating Labels and Styling - Part 2 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Thinking Through Code 21 maggio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,906 volte e gli è piaciuto 66 spettatori. Buona visione!