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 –
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Label" )
self .setGeometry( 0 , 0 , 400 , 300 )
self .label_1 = QLabel( 'Arial font' , self )
self .label_1.move( 100 , 100 )
self .label_1.setFont(QFont( 'Arial' , 10 ))
self .label_2 = QLabel( 'Times font' , self )
self .label_2.move( 100 , 120 )
self .label_2.setFont(QFont( 'Times' , 10 ))
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
26 Mar, 2020
Like Article
Save Article