马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
刚学pyqt5,这个对话框字体该怎么设置呢
代码如下import sys
from PyQt5.QtWidgets import (QWidget,QAction,QApplication,QFrame,QColorDialog,QLineEdit,QInputDialog,QPushButton)
from PyQt5.QtGui import QFont
class Example(QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def YaHei(self):
return QFont("Microsoft YaHei",13)
def initUI(self):
self.btn = QPushButton("对话框",self)
self.btn.setFont(self.YaHei())
self.btn.move(20,20)
self.btn.clicked.connect(self.showDialog)
"""创建文字输入框"""
self.le = QLineEdit(self)
self.le.resize(200,40)
self.le.move(130,20)
self.setGeometry(300,300,400,150)
self.setWindowTitle("对话框练习")
self.show()
def showDialog(self):
text,ok = QInputDialog.getText(self,"输入框","请输入文字")
if ok:
self.le.setText(str(text))
self.le.setFont(self.YaHei())
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
|