17.QFontDialog 字体选择对话框

 def initUI(self):
        self.setWindowTitle('QFontDialogDemo')
        self.setGeometry(500,500,300,200)

        fontButton = QPushButton('选择字体')
        fontLabel  = QLabel('hello 测试字体')
        fontButton.clicked.connect(lambda :self.getFont(fontLabel))

        layout = QVBoxLayout()
        layout.addWidget(fontButton)
        layout.addWidget(fontLabel)
        self.setLayout(layout)

    def getFont(self,fontLabel):
        font, ok = QFontDialog.getFont()
        if ok:
            fontLabel.setFont(font)

你可能感兴趣的:(PyQt5,python)