导库
from PyQt5.uic import *
核心代码
self.ui = loadUi(r'xxxx文件路径xxxx', self)
简单代码实例
import sys from PyQt5.uic import * from PyQt5.QtWidgets import * class firstWindow(QMainWindow): def __init__(self): super(firstWindow, self).__init__() self.ui = loadUi(r'E:\pycharm_Projects\test\ui\UiDesigner\firstEasyUi.ui', self) self.ui.pushButton.clicked.connect(self.clickToPrint) def clickToPrint(self): info = self.ui.textEdit.toPlainText() print(info) if __name__ == '__main__': app = QApplication(sys.argv) mainWindow = firstWindow() mainWindow.show() sys.exit(app.exec_())
标签:__,self,firstWindow,PyQt5,导入,ui,import From: https://www.cnblogs.com/gooutlook/p/17267214.html