A label is a graphical control element which displays text on a form. A label is generally used to identify a nearby text box or other widget. Some labels can respond to events such as mouse clicks, allowing the text of the label to be copied, but this is not standard user-interface practice.
In this article, we will see how to change the font and size of the text in Label, we can do this by using setFont() method.
Syntax : label.setFont(QFont(font_name, size))
Argument : It take two argument :
1. Font name it can be ‘Arial’, ‘Times’ etc.
2. Size to be set in integer.
Below is the Python implementation –
# importing the required libraries from PyQt5.QtWidgets import * from PyQt5.QtGui import * import sys class Window(QMainWindow): def __init__(self): super().__init__() # set the title self.setWindowTitle("Label") # setting the geometry of window self.setGeometry(0, 0, 400, 300) # creating a label widget # by default label will display at top left corner self.label_1 = QLabel('Arial font', self) # moving position self.label_1.move(100, 100) # setting font and size self.label_1.setFont(QFont('Arial', 10)) # creating a label widget # by default label will display at top left corner self.label_2 = QLabel('Times font', self) # moving position self.label_2.move(100, 120) # setting font and size self.label_2.setFont(QFont('Times', 10)) # show all the widgets self.show() # create pyqt5 app App = QApplication(sys.argv) # create the instance of our Window window = Window() # start the app sys.exit(App.exec()) |
Output :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- PyQt5 – How to change size of the Label | label.resize method
- PyQt5 – Change the text font and size in Push button
- PYGLET – Accessing Label Text Font Size Property
- PyQt5 Scrollable Label - Getting tool tip text of the label part
- wxPython - Change Button Label Font
- PyQt5 – How to change text of pre-existing label | setText method
- PYGLET – Accessing Label Text Font Name Property
- Python PyQt5 – How to change font and size of Status Bar Message
- PyQt5 – How to hide label | label.setHidden method
- PyQt5 Scrollable Label - Setting tool tip to the label part
- PyQt5 Scrollable Label – Setting tool tip duration to label part
- PyQt5 Scrollable Label – Getting tool tip duration of the label part
- PyQt5 Label – Checking if label is window type
- PyQt5 Label – Checking if label is widget type
- PyQt5 QSpinBox - Matching font with the System Font
- How to change the Tkinter label text?
- wxPython - Change font for text present in Radio Box
- PyQt5 - How to change style and size of text Progress Bar ?
- PyQt5 – How to change color of the label ?
- PyQt5 – Change background color of Label for anti hover state
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.

