Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
Label widget –
The Label widget is for rendering text. It supports ascii and unicode strings. Label is the text which we want to add on our window, give to the buttons and so on. On labels, we can apply the styling also i.e increase text, size, color and more.
Let’s see how to add Label to a Kivy window.
How to add a label ?
1) import kivy 2) import kivy App 3) import label 4) set minimum version (optional) 5) Extend the App class 6) overwrite the build function 7) Add and return label 8) Run the instance of class
Below is the code:
How to do Styling in label ?
How to markup the text ?
You can change the style of the text using Text Markup. The syntax is similar to above syntax but some more things are there.
More markup tags we can use –
[b][/b]-> Activate bold text
[i][/i]-> Activate italic text
[u][/u]-> Underlined text
[s][/s]-> Strikethrough text
[font=][/font]-> Change the font
[size=][/size]]-> Change the font size
[color=#][/color]-> Change the text color
[ref=][/ref]-> Add an interactive zone. The reference + bounding box inside the reference will be available in Label.refs
[anchor=]-> Put an anchor in the text. You can get the position of your anchor within the text with Label.anchors
[sub][/sub]-> Display the text at a subscript position relative to the text before it.
[sup][/sup]-> Display the text at a superscript position relative to the text before it.
- Python | Make a simple window using kivy
- Python | Window size Adjustment in Kivy
- PyQt5 Label – Checking if label is window type
- PyQt5 Label – Checking if shadow is window type
- PyQt5 - Move the Label Position within the window using Arrow Keys
- PyQt5 Scrollable Label – Setting tool tip duration to label part
- PyQt5 Scrollable Label – Getting tool tip duration of the label part
- PyQt5 Scrollable Label - Setting tool tip to the label part
- PyQt5 Scrollable Label - Getting tool tip text of the label part
- PyQt5 – How to change size of the Label | label.resize method
- PyQt5 Label – Checking if label is widget type
- PyQt5 – How to hide label | label.setHidden method
- Python | Bubble in kivy
- Python | Kivy .kv File
- Python | Scatter in kivy
- Python | StackLayout in Kivy
- Python| AnchorLayout in Kivy
- Python | Animation in Kivy
- Python | Canvas in kivy
- Python | Accordion in kivy
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai