PyQt5 UI文件的使用方法
作者:互联网
################################ # PyQt5中文网 - PyQt5全套视频教程 # # https://www.PyQt5.cn/ # # 主讲: 村长 # ################################ from PyQt5.Qt import * import sys from PyQt5.test1 import Ui_Form class Window(QWidget, Ui_Form): def __init__(self): super().__init__() self.setWindowTitle("UI文件使用 - PyQt5中文网") self.resize(600, 500) self.func_list() Ui_Form.setupUi(self,self) def slot1(self): print('QQQQQ') def func_list(self): self.func() def func(self): pass if __name__ == '__main__': app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
from PyQt5 import QtCore, QtGui, QtWidgets ################################ # PyQt5中文网 - PyQt5全套视频教程 # # https://www.PyQt5.cn/ # # 主讲: 村长 # ################################ from PyQt5.Qt import * import sys class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(678, 413) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) Form.setSizePolicy(sizePolicy) Form.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.widget = QtWidgets.QWidget(Form) self.widget.setGeometry(QtCore.QRect(180, 120, 281, 141)) self.widget.setObjectName("widget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.lineEdit_2 = QtWidgets.QLineEdit(self.widget) self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password) self.lineEdit_2.setObjectName("lineEdit_2") self.gridLayout.addWidget(self.lineEdit_2, 1, 2, 1, 1) self.label_2 = QtWidgets.QLabel(self.widget) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) self.lineEdit = QtWidgets.QLineEdit(self.widget) self.lineEdit.setObjectName("lineEdit") self.gridLayout.addWidget(self.lineEdit, 0, 2, 1, 1) self.label = QtWidgets.QLabel(self.widget) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.verticalLayout_2.addLayout(self.gridLayout) self.Btn = QtWidgets.QPushButton(self.widget) self.Btn.setMinimumSize(QtCore.QSize(20, 20)) self.Btn.setMaximumSize(QtCore.QSize(20000, 30)) self.Btn.setStyleSheet("background-color: rgb(255, 170, 0);") self.Btn.setFlat(False) self.Btn.setObjectName("Btn") self.verticalLayout_2.addWidget(self.Btn) self.Btn.raise_() self.retranslateUi(Form) self.Btn.clicked.connect(Form.slot1) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) self.label_2.setText(_translate("Form", "密码:")) self.label.setText(_translate("Form", "手机号:")) self.Btn.setToolTip(_translate("Form", "<html><head/><body><p>sss</p></body></html>")) self.Btn.setText(_translate("Form", "按钮"))
标签:文件,Form,self,label,PyQt5,QtWidgets,UI,Btn 来源: https://www.cnblogs.com/lvdongjie/p/16331451.html