pyqt6加载ui的源码文件
# Form implementation generated from reading ui file 'weather.ui' # # Created by: PyQt6 UI code generator 6.4.2 # # WARNING: Any manual changes made to this file will be lost when pyuic6 is # run again. Do not edit this file unless you know what you are doing. import sys from PyQt6 import QtCore, QtGui, QtWidgets from PyQt6.QtWidgets import QApplication, QWidget class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(400, 300) Form.setBaseSize(QtCore.QSize(400, 350)) self.label = QtWidgets.QLabel(parent=Form) self.label.setGeometry(QtCore.QRect(130, 80, 151, 61)) self.label.setTextFormat(QtCore.Qt.TextFormat.PlainText) self.label.setStyleSheet(""" background-color: red; color: white; padding: 10px; """) self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.label.setObjectName("label") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "四川天气预报")) self.label.setText(_translate("Form", "今天天气不错")) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) Form = QtWidgets.QWidget() ui = Ui_Form() ui.setupUi(Form) Form.show() sys.exit(app.exec())