From Dmitry Shachnev, 9 Months ago, written in Plain Text.
This paste will run down the curtain in 1 Month.
This paste is a reply to fonttest.py from The Compiler
- go back
Embed
Viewing differences between fonttest.py and Re: fonttest.py
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel
from PyQt5.QtGui import QFont, QFontDatabase

app = QApplication(sys.argv)
widget = QWidget()
layout = QVBoxLayout(widget)

font1 = QFont()
font1.setStyleHint(QFont.Monospace)
fam1 = font1.defaultFamily()
font1.setFamily(fam1)

font2 = QFont()
font2.setStyleHint(QFont.TypeWriter)
fam2 = font2.defaultFamily()
font2.setFamily(fam1)

font3 = QFontDatabase.systemFont(QFontDatabase.FixedFont)
fam3 = font3.family()

label1 = QLabel()
label1.setText(fam1)
label1.setFont(font1)
layout.addWidget(label1)

label2 = QLabel()
label2.setText(fam2)
label2.setFont(font2)
layout.addWidget(label2)

label3 = QLabel()
label3.setText(fam3)
label3.setFont(font3)
layout.addWidget(label3)

widget.show()
app.exec_()
This should be probably fam2 instead of fam1.