python
from PyQt5 import QtCore, QtGui, QtWidgets
from poseUI import Ui_Form
import sys
class ZhongKe(QtWidgets.QMainWindow, Ui_Form):
def __init__(self):
super(ZhongKe,self).__init__()
self.setupUi(self)
if __name__ == '__main__':
from PyQt5 import QtCore
# QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) # 自适应分辨率
app = QtWidgets.QApplication(sys.argv)
ui = ZhongKe()
ui.show()
sys.exit(app.exec_())
二. poseUi.py(pose.ui------>poseUi.py)
命令端输入 pyuic5 -o poseUi.py pose.ui
python
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(1164, 836)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(650, 470, 75, 24))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(530, 470, 75, 24))
self.pushButton_2.setObjectName("pushButton_2")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "PushButton"))
三. ui无法调用鼠标事件解决办法
这是导入ui文件的方式不对
python
from PyQt5 import QtWidgets, uic
import sys
form_class = uic.loadUiType('new.ui')[0]
class Ui(QtWidgets.QMainWindow, form_class):
def __init__(self):
super(Ui, self).__init__()
self.setupUi(self)
if __name__=='__main__':
app = QtWidgets.QApplication(sys.argv)
window = Ui()
window.show()
sys.exit(app.exec_())
四.调用成功后界面显示不全
可能是因为加了分页,取消即可