def accept(self): try: self.setParamValues() msg = self.alg._checkParameterValuesBeforeExecuting() if msg: QMessageBox.warning( self, self.tr('Unable to execute algorithm'), msg) return description = algAsDict(self.alg) description["name"] = self.settingsPanel.txtName.text().strip() description["group"] = self.settingsPanel.txtGroup.text().strip() if not (description["name"] and description["group"]): self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1) return validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:' filename = ''.join(c for c in description["name"] if c in validChars).lower() + ".json" filepath = os.path.join(preconfiguredAlgorithmsFolder(), filename) with open(filepath, "w") as f: json.dump(description, f) algList.reloadProvider('preconfigured') except AlgorithmDialogBase.InvalidParameterValue as e: try: self.buttonBox.accepted.connect(lambda: e.widget.setPalette(QPalette())) palette = e.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) e.widget.setPalette(palette) self.parent.bar.pushMessage("", self.tr('Missing parameter value: {0}').format( e.parameter.description), level=QgsMessageBar.WARNING, duration=5) return except: QMessageBox.critical(self, self.tr('Unable to execute algorithm'), self.tr('Wrong or missing parameter values')) self.close()
def accept(self): try: self.setParamValues() msg = self.alg._checkParameterValuesBeforeExecuting() if msg: QMessageBox.warning( self, self.tr('Unable to execute algorithm'), msg) return description = algAsDict(self.alg) description["name"] = self.settingsPanel.txtName.text().strip() description["group"] = self.settingsPanel.txtGroup.text().strip() if not (description["name"] and description["group"]): self.tabWidget.setCurrentIndex(1) return validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:' filename = ''.join(c for c in description["name"] if c in validChars).lower() + ".json" filepath = os.path.join(preconfiguredAlgorithmsFolder(), filename) with open(filepath, "w") as f: json.dump(description, f) self.toolbox.updateProvider('preconfigured') except AlgorithmDialogBase.InvalidParameterValue as e: try: self.buttonBox.accepted.connect(lambda: e.widget.setPalette(QPalette())) palette = e.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) e.widget.setPalette(palette) self.lblProgress.setText( self.tr('<b>Missing parameter value: %s</b>') % e.parameter.description) return except: QMessageBox.critical(self, self.tr('Unable to execute algorithm'), self.tr('Wrong or missing parameter values')) self.close()
def accept(self): context = dataobjects.createContext() try: parameters = self.getParameterValues() self.setOutputValues() ok, msg = self.algorithm().checkParameterValues( parameters, context) if not ok: QMessageBox.warning(self, self.tr('Unable to execute algorithm'), msg) return description = algAsDict(self.algorithm()) description["name"] = self.settingsPanel.txtName.text().strip() description["group"] = self.settingsPanel.txtGroup.text().strip() if not (description["name"] and description["group"]): self.tabWidget().setCurrentIndex(self.tabWidget().count() - 1) return validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:' filename = ''.join(c for c in description["name"] if c in validChars).lower() + ".json" filepath = os.path.join(preconfiguredAlgorithmsFolder(), filename) with open(filepath, "w") as f: json.dump(description, f) QgsApplication.processingRegistry().providerById( 'preconfigured').refreshAlgorithms() except AlgorithmDialogBase.InvalidParameterValue as e: try: self.buttonBox().accepted.connect( lambda: e.widget.setPalette(QPalette())) palette = e.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) e.widget.setPalette(palette) self.messageBar().pushMessage( "", self.tr('Missing parameter value: {0}').format( e.parameter.description()), level=Qgis.Warning, duration=5) return except: QMessageBox.critical( self, self.tr('Unable to execute algorithm'), self.tr('Wrong or missing parameter values')) self.close()
def accept(self): context = dataobjects.createContext() try: parameters = self.getParameterValues() self.setOutputValues() ok, msg = self.algorithm().checkParameterValues(parameters, context) if not ok: QMessageBox.warning( self, self.tr('Unable to execute algorithm'), msg) return description = algAsDict(self.algorithm()) description["name"] = self.settingsPanel.txtName.text().strip() description["group"] = self.settingsPanel.txtGroup.text().strip() if not (description["name"] and description["group"]): self.tabWidget().setCurrentIndex(self.tabWidget().count() - 1) return validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:' filename = ''.join(c for c in description["name"] if c in validChars).lower() + ".json" filepath = os.path.join(preconfiguredAlgorithmsFolder(), filename) with open(filepath, "w") as f: json.dump(description, f) QgsApplication.processingRegistry().providerById('preconfigured').refreshAlgorithms() except AlgorithmDialogBase.InvalidParameterValue as e: try: self.buttonBox().accepted.connect(lambda: e.widget.setPalette(QPalette())) palette = e.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) e.widget.setPalette(palette) self.messageBar().pushMessage("", self.tr('Missing parameter value: {0}').format( e.parameter.description()), level=Qgis.Warning, duration=5) return except: QMessageBox.critical(self, self.tr('Unable to execute algorithm'), self.tr('Wrong or missing parameter values')) self.close()
def accept(self): try: self.setParamValues() msg = self.alg._checkParameterValuesBeforeExecuting() if msg: QMessageBox.warning(self, self.tr("Unable to execute algorithm"), msg) return description = algAsDict(self.alg) description["name"] = self.settingsPanel.txtName.text().strip() description["group"] = self.settingsPanel.txtGroup.text().strip() if not (description["name"] and description["group"]): self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1) return validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:" filename = "".join(c for c in description["name"] if c in validChars).lower() + ".json" filepath = os.path.join(preconfiguredAlgorithmsFolder(), filename) with open(filepath, "w") as f: json.dump(description, f) algList.reloadProvider("preconfigured") except AlgorithmDialogBase.InvalidParameterValue as e: try: self.buttonBox.accepted.connect(lambda: e.widget.setPalette(QPalette())) palette = e.widget.palette() palette.setColor(QPalette.Base, QColor(255, 255, 0)) e.widget.setPalette(palette) self.parent.bar.pushMessage( "", self.tr("Missing parameter value: %s") % e.parameter.description, level=QgsMessageBar.WARNING, duration=5, ) return except: QMessageBox.critical( self, self.tr("Unable to execute algorithm"), self.tr("Wrong or missing parameter values") ) self.close()