def accept(self): checkCRS = ProcessingConfig.getSetting( ProcessingConfig.WARN_UNMATCHING_CRS) keepOpen = ProcessingConfig.getSetting( ProcessingConfig.KEEP_DIALOG_OPEN) self.showDebug = ProcessingConfig.getSetting( ProcessingConfig.SHOW_DEBUG_IN_DIALOG) try: self.setParamValues() if checkCRS and not self.alg.checkInputCRS(): reply = QMessageBox.question(self, "Unmatching CRS's", 'Layers do not all use the same CRS.\n' + 'This can cause unexpected results.\n' + 'Do you want to continue?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.No: return msg = self.alg.checkParameterValuesBeforeExecuting() if msg: QMessageBox.critical(self, 'Unable to execute algorithm', msg) return self.runButton.setEnabled(False) self.buttonBox.button( QtGui.QDialogButtonBox.Close).setEnabled(False) buttons = self.paramTable.iterateButtons self.iterateParam = None for i in range(len(buttons.values())): button = buttons.values()[i] if button.isChecked(): self.iterateParam = buttons.keys()[i] break self.tabWidget.setCurrentIndex(1) # Log tab self.progress.setMaximum(0) self.progressLabel.setText('Processing algorithm...') QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) self.setInfo('<b>Algorithm %s starting...</b>' % self.alg.name) if self.iterateParam: if UnthreadedAlgorithmExecutor.runalgIterating(self.alg, self.iterateParam, self): self.finish() else: QApplication.restoreOverrideCursor() if not keepOpen: self.close() else: self.resetGUI() else: command = self.alg.getAsCommand() if command: ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM, command) if UnthreadedAlgorithmExecutor.runalg(self.alg, self): self.finish() else: QApplication.restoreOverrideCursor() if not keepOpen: self.close() else: self.resetGUI() except AlgorithmExecutionDialog.InvalidParameterValue, ex: try: self.buttonBox.accepted.connect(lambda : ex.widget.setPalette(QPalette())) palette = ex.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) ex.widget.setPalette(palette) self.progressLabel.setText('<b>Missing parameter value: ' + ex.parameter.description + '</b>') return except: QMessageBox.critical(self, 'Unable to execute algorithm', 'Wrong or missing parameter values')
def accept(self): checkCRS = ProcessingConfig.getSetting( ProcessingConfig.WARN_UNMATCHING_CRS) keepOpen = ProcessingConfig.getSetting( ProcessingConfig.KEEP_DIALOG_OPEN) try: self.setParamValues() if checkCRS and not self.alg.checkInputCRS(): reply = QMessageBox.question( self, "Unmatching CRS's", 'Layers do not all use the same CRS.\n' + 'This can cause unexpected results.\n' + 'Do you want to continue?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.No: return msg = self.alg.checkParameterValuesBeforeExecuting() if msg: QMessageBox.critical(self, 'Unable to execute algorithm', msg) return self.runButton.setEnabled(False) self.buttonBox.button( QtGui.QDialogButtonBox.Close).setEnabled(False) buttons = self.paramTable.iterateButtons self.iterateParam = None for i in range(len(buttons.values())): button = buttons.values()[i] if button.isChecked(): self.iterateParam = buttons.keys()[i] break self.tabWidget.setCurrentIndex(1) # Log tab self.progress.setMaximum(0) self.progressLabel.setText('Processing algorithm...') QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) self.setInfo('<b>Algorithm %s starting...</b>' % self.alg.name) if self.iterateParam: if UnthreadedAlgorithmExecutor.runalgIterating( self.alg, self.iterateParam, self): self.finish() else: QApplication.restoreOverrideCursor() if not keepOpen: self.close() else: self.resetGUI() else: command = self.alg.getAsCommand() if command: ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM, command) if UnthreadedAlgorithmExecutor.runalg(self.alg, self): self.finish() else: QApplication.restoreOverrideCursor() if not keepOpen: self.close() else: self.resetGUI() except AlgorithmExecutionDialog.InvalidParameterValue, ex: try: self.buttonBox.accepted.connect( lambda: ex.widget.setPalette(QPalette())) palette = ex.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) ex.widget.setPalette(palette) self.progressLabel.setText('<b>Missing parameter value: ' + ex.parameter.description + '</b>') return except: QMessageBox.critical(self, 'Unable to execute algorithm', 'Wrong or missing parameter values')