pyqt QMessageBox 所带的按钮是英文 在写中文软件上面看着好烦人,
研究了一下 找到了 显示中文按钮的方法
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QMessageBox, QLineEdit, QWidget, QCheckBox, QPushButton, QHBoxLayout
from enum import Enum
mesboxtype = [
QMessageBox.NoIcon,
QMessageBox.Information,
QMessageBox.Warning,
QMessageBox.Critical,
QMessageBox.Question]
class mesbox_base(object):
none = 0
info = 1
waring = 2
err = 3
question = 4
def btn_one(self, icontype, showmes, titelmes='提示框', icon='./data/logo.ico'):
'''
单按钮对话框 \n
icontype
none = 0
info = 1
waring = 2
err = 3
question = 4
showmes 显示信息
'''
re = QMessageBox(
mesboxtype[icontype], titelmes, showmes)
re.setWindowIcon(QIcon(icon))
ye = re.addButton('确定', QMessageBox.YesRole)
re.exec_()
def btn_two(self, icontype, showmes, titelmes='提示框', icon='./data/logo.ico'):
'''
双按钮对话框 \n
icontype
none = 0
info = 1
waring = 2
err = 3
question = 4
showmes 显示信息
'''
re = QMessageBox(
mesboxtype[icontype], titelmes, showmes)
re.setWindowIcon(QIcon(icon))
btn_ok = re.addButton('确定', QMessageBox.YesRole)
btn_no = re.addButton('取消', QMessageBox.NoRole)
re.exec_()
return re.clickedButton() == btn_ok
实例化类 调用方法就能使用了