def newAction(self, actionCode, actionName, kwargs): self.showMask() self.repaint() newtab = TabWidget.Tab(actionCode, actionName, kwargs) self.workTab.addTab(newtab, QIcon("Resource/icon/Icon_tag.ico"), actionName) newtab.logGenerated.connect(self.appenText) try: newtab.run() except Exception as e: QMessageBox.critical(self, "错误", traceback.format_exc(), QMessageBox.Ok) self.maskwidget.hide()
def initUI(self): #设置样式 self.setStyleSheet(open("UI/MainWindow.qss", 'r').read()) #获取屏幕尺寸 screen = QDesktopWidget().screenGeometry() self.screen_width = screen.width() self.screen_height = screen.height() # 设置中心窗口部件为QTextEdit self.verticalSplitter = QSplitter(Qt.Vertical) self.setCentralWidget(self.verticalSplitter) #self.scroll.setGeometry(QtCore.QRect(100,100, 2000, 1000)) #标签管理 self.workTab = TabWidget.WorkTab() self.setObjectName("workTab") self.setGeometry( QtCore.QRect(0, 0, self.screen_width - 40, self.screen_height - 170)) # self.scorllTextEdit = QScrollArea() self.textEdit = QTextEdit() self.textEdit.setText('执行记录:') #self.textEdit.setStyleSheet("background:white;height:20%") self.textEdit.setReadOnly(True) self.verticalSplitter.addWidget(self.workTab) self.verticalSplitter.addWidget(self.textEdit) # 定义一系列的Action # 新建 newAction = QtWidgets.QPushButton( QIcon('Resource/icon/Icon_create.ico'), '内容填充') newAction.setShortcut('Ctrl+N') newAction.setStatusTip('内容填充') newAction.clicked.connect(self.new) #下拉框新增 self.button_saveAs = QtWidgets.QPushButton() self.button_saveAs.setText("另存为") #openAction.setShortcut('Ctrl+O') self.button_saveAs.setStatusTip('另存为') self.button_saveAs.clicked.connect(self.open) # 基础校验 # self.button_checkValue = QtWidgets.QPushButton(QIcon('Resource/icon/Icon_run.ico'), '基础资产校验') # self.button_checkValue.setText("基础资产校验") # self.button_checkValue.setToolTip('基础资产校验') # self.button_checkValue.clicked.connect(self.valueCheck) self.comboBox_baseCheck = DropDownMenu() self.comboBox_baseCheck.setObjectName("BaseCheck") for i in range(len(self.BaseCheck)): self.comboBox_baseCheck.addItem(self.BaseCheck[i], "") self.comboBox_baseCheck.setItemIcon( i, QIcon('Resource/icon/Icon_run.ico')) self.comboBox_baseCheck.currentIndexChanged.connect(self.showBaseCheck) # 不良校验 self.button_NoncheckValue = QtWidgets.QPushButton( QIcon('Resource/icon/Icon_run.ico'), '不良资产校验') self.button_NoncheckValue.setText("不良资产校验") self.button_NoncheckValue.setToolTip('不良资产校验') self.button_NoncheckValue.clicked.connect(self.NonvalueCheck) # 池分布校验 self.button_PoolcheckValue = QtWidgets.QPushButton( QIcon('Resource/icon/Icon_run.ico'), '池分布校验') self.button_PoolcheckValue.setText("池分布校验") self.button_PoolcheckValue.setToolTip('池分布校验') self.button_PoolcheckValue.clicked.connect(self.PoolvalueCheck) #批量运行 self.button_multiRun = QtWidgets.QPushButton( QIcon("Resource/icon/Icon_multiRun.ico"), '批量运行') self.button_multiRun.setText("批量填充") self.button_multiRun.setShortcut('Ctrl+M') self.button_multiRun.setStatusTip('批量填充') self.button_multiRun.clicked.connect(self.multiRun) # 保存 saveAction = QtWidgets.QPushButton( QIcon('Resource/icon/Icon_save.ico'), '保存') saveAction.setShortcut('Ctrl+S') saveAction.setStatusTip('保存') saveAction.clicked.connect( lambda: self.save(self.workTab.currentIndex())) #保存全部 saveAllAction = QtWidgets.QPushButton() saveAllAction.setStatusTip('保存全部') saveAllAction.setText("保存全部") saveAllAction.clicked.connect(self.saveAll) #配置管理 self.comboBox_setting = DropDownMenu() self.comboBox_setting.setObjectName("Setting") for i in range(len(self.Settings)): self.comboBox_setting.addItem(self.Settings[i], "") self.comboBox_setting.setItemIcon( i, QIcon("Resource/icon/Icon_setting.ico")) self.comboBox_setting.currentIndexChanged.connect(self.showManager) # 添加菜单 # 对于菜单栏,注意menuBar,menu和action三者之间的关系 # 首先取得Qself自带的menuBar:menubar = self.menuBar() # 然后在menuBar里添加Menu:fileMenu = menubar.addMenu('&File') # 最后在Menu里添加Action:fileMenu.addAction(newAction) # 添加工具栏 # 对于工具栏,同样注意ToolBar和Action之间的关系 # 首先在Qself中添加ToolBar:tb1 = self.addToolBar('File') # 然后在ToolBar中添加Action:tb1.addAction(newAction) tb1 = self.addToolBar('Edit') tb1.addWidget(newAction) tb1.addWidget(self.button_multiRun) #注释内容填充和批量填充 # tb1.addWidget(self.comboBox_baseCheck) # tb1.addWidget(self.button_NoncheckValue) # tb1.addWidget(self.button_PoolcheckValue) tb1.addWidget(saveAction) # tb1.addWidget(self.button_saveAs) #tb1.addWidget(saveAllAction) tb1.addWidget(self.comboBox_setting) #self.verticalSplitter.setStyleSheet("background-color: rgb(222, 222, 222);") self.statusBar() #遮罩 self.maskwidget = QWidget(self) self.maskwidget.setObjectName("Mask") self.maskwidget.setGeometry(0, 0, 1920, 1080) self.maskwidget.raise_() self.masklabel = QLabel(self.maskwidget) self.maskwidget.setGeometry(0, 0, 1920, 1080) self.masklabel.setText("loading...") #self.masklabel.move(self.maskwidget.rect().center()) # self.loadingGif = QMovie('Resource/icon/loading-image.gif') # self.masklabel.setMovie(self.loadingGif) # self.loadingGif.start() self.maskwidget.hide() #show self.setObjectName("MainWindow") self.setGeometry(0, 0, 1280, 760) self.setWindowTitle("Excel转换") self.setWindowIcon(QIcon('Resource/icon/Icon_table.ico')) #self.center() self.show() self.showMaximized()