Skip to content
Permalink
Browse files

[processing] use checkbox for boolean parameters

  • Loading branch information
alexbruy committed Sep 24, 2014
1 parent 986bd1c commit ace704a4249de1419a4290670b94f7ba4bd04878
@@ -10,7 +10,8 @@
Email : volayaf at gmail dot com
otb at c-s dot fr (CS SI)
Contributors : Victor Olaya
Alexia Mondot (CS SI) - managing the new parameter ParameterMultipleExternalInput
Alexia Mondot (CS SI) - managing the new parameter
ParameterMultipleExternalInput
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@@ -32,7 +33,7 @@
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.QtWebKit import *

from processing.core.ProcessingLog import ProcessingLog
from processing.core.ProcessingConfig import ProcessingConfig
@@ -45,53 +46,52 @@
from processing.tools import dataobjects
from qgis.utils import iface

class AlgorithmExecutionDialog(QtGui.QDialog):
class AlgorithmExecutionDialog(QDialog):

class InvalidParameterValue(Exception):

def __init__(self, param, widget):
(self.parameter, self.widget) = (param, widget)

def __init__(self, alg, mainWidget):
QtGui.QDialog.__init__(self, iface.mainWindow(), QtCore.Qt.WindowSystemMenuHint
| QtCore.Qt.WindowTitleHint)
QDialog.__init__(self, iface.mainWindow(),
Qt.WindowSystemMenuHint | Qt.WindowTitleHint)
self.executed = False
self.mainWidget = mainWidget
self.alg = alg
self.resize(650, 450)
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close)
self.runButton = QtGui.QPushButton()
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
self.runButton = QPushButton()
self.runButton.setText('Run')
self.buttonBox.addButton(self.runButton,
QtGui.QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.runButton, QDialogButtonBox.ActionRole)
self.runButton.clicked.connect(self.accept)
self.setWindowTitle(self.alg.name)
self.progressLabel = QtGui.QLabel()
self.progress = QtGui.QProgressBar()
self.progressLabel = QLabel()
self.progress = QProgressBar()
self.progress.setMinimum(0)
self.progress.setMaximum(100)
self.progress.setValue(0)
self.verticalLayout = QtGui.QVBoxLayout(self)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(6)
self.verticalLayout.setMargin(9)
self.tabWidget = QtGui.QTabWidget()
self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(300)
self.tabWidget.addTab(self.mainWidget, 'Parameters')
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
self.tabWidget.addTab(self.logText, 'Log')
self.webView = QtWebKit.QWebView()
self.webView = QWebView()
html = None
url = None
isText, help = self.alg.help()
if help is not None:
if isText:
html = help;
else:
url = QtCore.QUrl(help)
url = QUrl(help)
else:
html = '<h2>Sorry, no help is available for this \
algorithm.</h2>'
@@ -121,17 +121,17 @@ def setParamValues(self):
continue
if isinstance(param, ParameterExtent):
continue
if not self.setParamValue(param,
self.paramTable.valueItems[param.name]):
if not self.setParamValue(
param, self.paramTable.valueItems[param.name]):
raise AlgorithmExecutionDialog.InvalidParameterValue(param,
self.paramTable.valueItems[param.name])

for param in params:
if isinstance(param, ParameterExtent):
if not self.setParamValue(param,
self.paramTable.valueItems[param.name]):
raise AlgorithmExecutionDialog.InvalidParameterValue(param,
self.paramTable.valueItems[param.name])
if not self.setParamValue(
param, self.paramTable.valueItems[param.name]):
raise AlgorithmExecutionDialog.InvalidParameterValue(
param, self.paramTable.valueItems[param.name])

for output in outputs:
if output.hidden:
@@ -158,7 +158,7 @@ def setParamValue(self, param, widget):
except:
return param.setValue(widget.getValue())
elif isinstance(param, ParameterBoolean):
return param.setValue(widget.currentIndex() == 0)
return param.setValue(widget.isChecked())
elif isinstance(param, ParameterSelection):
return param.setValue(widget.currentIndex())
elif isinstance(param, ParameterFixedTable):
@@ -199,17 +199,17 @@ def accept(self):
'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:
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No)
if reply == QMessageBox.No:
return
msg = self.alg.checkParameterValuesBeforeExecuting()
if msg:
QMessageBox.warning(self, 'Unable to execute algorithm', msg)
return
self.runButton.setEnabled(False)
self.buttonBox.button(
QtGui.QDialogButtonBox.Close).setEnabled(False)
QDialogButtonBox.Close).setEnabled(False)
buttons = self.paramTable.iterateButtons
self.iterateParam = None

@@ -289,7 +289,7 @@ def resetGUI(self):
self.progress.setMaximum(100)
self.progress.setValue(0)
self.runButton.setEnabled(True)
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(True)
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)

def setInfo(self, msg, error=False):
if error:

0 comments on commit ace704a

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