
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python - Add Label to kivy window
Kivy is an pen source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. It is used to develop the Android application, as well as Desktops applications. In this article we will see how to add labels to the windows created through Kivy.
Creating Label
In the below example we create a window and give it a custom label by using Label function available in uix.lable module. Once we run the app with this code we get the new window showing the custom label.
Example
from kivy.app import App from kivy.uix.label import Label class NewLabel(App): def build(self): # Label text to be edited lbl = Label(text ="Hello Label Text ! ") return lbl NewLabel().run()
Running the above code gives us the following result −
Output
decorating the Label
We can also adjust the font size and colour of the label with additional parameters available as part of the Label function.
Example
from kivy.app import App from kivy.uix.label import Label class NewLabel(App): def build(self): # Label text to be edited lbl = Label(text ="Hello Label Text ! \nwelcome to the world of Kivy",font_size='30sp',color = [0.56, 0.56, 0.24, 1]) return lbl NewLabel().run()
Running the above code gives us the following result −
Output
- Related Articles
- Python - Window size Adjustment in Kivy
- How to add custom fonts in Kivy - Python?
- How to add Matplotlib graph in Kivy?
- How to add drag behavior in kivy widget?
- Python - AnchorLayout in Kivy
- Python Checkbox widget in Kivy?
- Python Float Layout in Kivy?
- Python - BoxLayout widget in Kivy
- Python - Button Action in Kivy
- Introduction to Kivy; A Cross-platform Python Framework
- Python - Working with buttons in Kivy
- How to add Label width in Tkinter?
- Add Red label with Bootstrap
- How to add axis label to chart in Excel?
- How to add a margin to a tkinter window?

Advertisements