Skip to content
Permalink
Browse files

Less obtrusive "missing parameter" error message in Algorithm Executi…

…on Dialog. c.f #5381

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@342 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Aug 10, 2012
1 parent 12c014e commit 1433a12826dd28955954489c66cb57f426bf7c9a
Showing with 26 additions and 10 deletions.
  1. +26 −10 src/sextante/gui/AlgorithmExecutionDialog.py
@@ -37,6 +37,10 @@
_fromUtf8 = lambda s: s

class AlgorithmExecutionDialog(QtGui.QDialog):
class InvalidParameterValue(Exception):
def __init__(self, param, widget):
self.parameter, self.widget = param, widget

'''Base class for dialogs that execute algorithms'''
def __init__(self, alg, mainWidget):
QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
@@ -114,15 +118,15 @@ def setParamValues(self):
if isinstance(param, ParameterExtent):
continue
if not self.setParamValue(param, self.paramTable.valueItems[param.name]):
return False
raise AlgorithmExecutionDialog.InvalidParameterValue(param, self.paramTable.valueItems[param.name])

for param in params:
if isinstance(param, ParameterExtent):
value = self.paramTable.valueItems[param.name].getValue()
if value is not None:
param.value = value
else:
return False
raise AlgorithmExecutionDialog.InvalidParameterValue(param, self.paramTable.valueItems[param.name])

for output in outputs:
if output.hidden:
@@ -168,16 +172,22 @@ def setParamValue(self, param, widget):
return param.setValue(unicode(widget.toPlainText()))
else:
return param.setValue(unicode(widget.text()))

else:
return param.setValue(unicode(widget.text()))

@pyqtSlot()
def accept(self):
if self.setParamValues():
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
useThread = SextanteConfig.getSetting(SextanteConfig.USE_THREADS)
try:
self.setParamValues()
msg = self.alg.checkParameterValuesBeforeExecuting()
if msg:
QMessageBox.critical(self, "Unable to execute algorithm", msg)
if keepOpen or useThread:
self.setInfo("Unable to execute algorithm: %s" % msg, True)
self.tabWidget.setCurrentIndex(1) # log tab
else:
QMessageBox.critical(self, "Unable to execute algorithm", msg)
return
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(False)
@@ -193,7 +203,6 @@ def accept(self):
self.progress.setMaximum(0)
self.progressLabel.setText("Processing algorithm...")
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
useThread = SextanteConfig.getSetting(SextanteConfig.USE_THREADS)
if useThread:
if iterateParam:
self.algEx = AlgorithmExecutor(self.alg, iterateParam)
@@ -227,7 +236,6 @@ def accept(self):
self.finish()
else:
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
self.close()
else:
@@ -238,8 +246,16 @@ def accept(self):
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(True)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(False)
self.tabWidget.setCurrentIndex(1) # log tab
else:
QMessageBox.critical(self, "Unable to execute algorithm", "Wrong or missing parameter values")
except AlgorithmExecutionDialog.InvalidParameterValue as 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</b>")
return
except:
QMessageBox.critical(self, "Unable to execute algorithm", "Wrong or missing parameter values")

@pyqtSlot()
def finish(self):

0 comments on commit 1433a12

Please sign in to comment.
You can’t perform that action at this time.