Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify the size and the type of the font

Tags:

python

pyqt

I'm a beginner in Pyqt and I made the main form but I don't know how to modify the size and the type of the font in the Qlabel?

def __init__(self):
    QtGui.QMainWindow.__init__(self)
    self.center()
    self.setWindowTitle('GBLtda Database')
    self.setStyleSheet("background-color: white")
    self.resize(1028, 720)
    label = QtGui.QLabel('GB DATABASE', self)
    label.move(15, 10)
    self.setWindowIcon(QtGui.QIcon('db.png'))  
like image 978
Margarita Gonzalez Avatar asked Dec 26 '22 09:12

Margarita Gonzalez


2 Answers

Using stylesheets:

#for the whole widget   
self.setStyleSheet("QLabel {font: 30pt Comic Sans MS}")
#Just for this label
label.setStyleSheet("font: 30pt Comic Sans MS")
like image 200
M4rtini Avatar answered Dec 31 '22 08:12

M4rtini


The simplest way is to set the font using setFont(QFont) method.

label.setFont(QFont('Arial', 20))
like image 36
qurban Avatar answered Dec 31 '22 09:12

qurban