调用方法1:
from PyQt5.uic import loadUiType ui, _ = loadUiType('login.ui')
调用方法2:在ui.py文件的最后添加如下代码:
if __name__ == "__main__":
import sys
from PyQt5 import QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) app = QtWidgets.QApplication(sys.argv)
Window = QtWidgets.QMainWindow()#注意窗口类型
ui = Ui_Form()
ui.setupUi(Window)
Window.show()
sys.exit(app.exec_())