from PyQt5.QtWidgets import QApplication, QLabel from PyQt5.QtGui import QFont app = QApplication([]) label = QLabel('Hello World') font = QFont('Arial', 16) label.setFont(font) label.show() app.exec_()
from PyQt5.QtWidgets import QApplication, QRadioButton, QLabel, QVBoxLayout, QWidget from PyQt5.QtGui import QFont app = QApplication([]) window = QWidget() layout = QVBoxLayout() font = QFont('Arial', 16) label = QLabel('Select a font:') layout.addWidget(label) radio_button1 = QRadioButton('Arial') radio_button1.setFont(font) layout.addWidget(radio_button1) radio_button2 = QRadioButton('Times New Roman') radio_button2.setFont(font) layout.addWidget(radio_button2) window.setLayout(layout) window.show() app.exec_()In this example, we create a window that contains two radio buttons and a label. We want to use the same font for all the widgets in the window, so we create a QFont object specifying the font family and font size that we want to use. We then set the font of each radio button using setFont() method, and finally, we show the window on the screen. Package library: PyQt5.QtGui