pyuic5 -o untitled.py untitled.ui
# -*- coding: utf-8 -*- import os,sys,time,re import xlrd from PyQt5.QtWidgets import QMainWindow,QMessageBox from PyQt5.uic import loadUi from PyQt5.QtWidgets import QApplication,QDialog from PyQt5 import QtCore,QtGui from untitled import Ui_MainWindow class SmartBit_Tool(QMainWindow): host_ip = '192.168.8.85' username = 'su' password = 'SMB-6000' excel_file = 'IP_Name.xlsx' smart_ip_list_file = 'smart_ip_list.txt' srcFilename = os.path.join('\\\\192.168.8.123\\software', excel_file) desFilename = os.path.join(os.getcwd(),excel_file) smart_ip_list_file = os.path.join(os.getcwd(),smart_ip_list_file) def __init__(self, *args): super(SmartBit_Tool, self).__init__(*args) self.ret_ping_test = False self.ui = Ui_MainWindow() #實例化窗口 self.ui.setupUi(self) #顯示窗口
# -*- coding: utf-8 -*- import os,sys,time,re import xlrd from PyQt5.QtWidgets import QMainWindow,QMessageBox from PyQt5.uic import loadUi from PyQt5.QtWidgets import QApplication,QDialog from PyQt5 import QtCore,QtGui class SmartBit_Tool(QMainWindow): def __init__(self, *args): super(SmartBit_Tool, self).__init__(*args) loadUi('untitled.ui', self) self.setWindowTitle('SmartBit_Get_User')
如上方式使用loadUI函數直接調用*.ui,未進行pyuic5生成untitled.py,對話框顯示跟QT設計排版存在差別,不推薦使用!html
請參考:http://www.javashuo.com/article/p-zekmgjka-gu.htmlpython