Skip to content
Permalink
Browse files

Fix evaluation of Python wrapper values

  • Loading branch information
nyalldawson committed Sep 4, 2018
1 parent 70c1680 commit 8082497724e871dd3c8b19ae402bc9df419350c6
@@ -59,6 +59,7 @@
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase
from processing.gui.AlgorithmExecutor import executeIterating, execute
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.gui.wrappers import WidgetWrapper

from processing.tools import dataobjects

@@ -103,10 +104,11 @@ def getParameterValues(self):
except KeyError:
continue

try:
widget = wrapper.wrappedWidget()
except AttributeError:
if issubclass(wrapper.__class__, WidgetWrapper):
widget = wrapper.widget
else:
widget = wrapper.wrappedWidget()

if widget is None:
continue

@@ -83,8 +83,8 @@ def accept(self):
if param.flags() & QgsProcessingParameterDefinition.FlagHidden or param.isDestination():
continue
wrapper = self.mainWidget().wrappers[row][col]
parameters[param.name()] = wrapper.value()
if not param.checkValueIsAcceptable(wrapper.value()):
parameters[param.name()] = wrapper.parameterValue()
if not param.checkValueIsAcceptable(wrapper.parameterValue()):
self.messageBar().pushMessage("", self.tr('Wrong or missing parameter value: {0} (row {1})').format(
param.description(), row + 1),
level=Qgis.Warning, duration=5)
@@ -36,9 +36,8 @@
QgsApplication,
QgsSettings,
QgsProcessingParameterDefinition)
from qgis.gui import QgsAbstractProcessingParameterWidgetWrapper

from processing.gui.wrappers import WidgetWrapperFactory
from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper
from processing.gui.BatchOutputSelectionPanel import BatchOutputSelectionPanel

from processing.tools import dataobjects
@@ -235,7 +234,7 @@ def save(self):
def setCellWrapper(self, row, column, wrapper, context):
self.wrappers[row][column] = wrapper

is_cpp_wrapper = issubclass(wrapper.__class__, QgsAbstractProcessingParameterWidgetWrapper)
is_cpp_wrapper = not issubclass(wrapper.__class__, WidgetWrapper)
if is_cpp_wrapper:
widget = wrapper.createWrappedWidget(context)
else:
@@ -38,14 +38,10 @@
QgsProcessingParameterExtent,
QgsProcessingParameterPoint,
QgsProcessingParameterFeatureSource,
QgsProcessingOutputVectorLayer,
QgsProcessingOutputRasterLayer,
QgsProcessingParameterRasterDestination,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterVectorDestination,
QgsProject)
from qgis.gui import (QgsGui,
QgsAbstractProcessingParameterWidgetWrapper)

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication, Qt
@@ -54,7 +50,7 @@
from qgis.PyQt.QtGui import QIcon

from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel
from processing.gui.wrappers import WidgetWrapperFactory
from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper
from processing.tools.dataobjects import createContext

pluginPath = os.path.split(os.path.dirname(__file__))[0]\
@@ -123,14 +119,14 @@ def initWidgets(self):
else:
wrapper = WidgetWrapperFactory.create_wrapper(param, self.parent)
self.wrappers[param.name()] = wrapper
is_cpp_wrapper = issubclass(wrapper.__class__, QgsAbstractProcessingParameterWidgetWrapper)
if is_cpp_wrapper:
is_python_wrapper = issubclass(wrapper.__class__, WidgetWrapper)
if not is_python_wrapper:
widget = wrapper.createWrappedWidget(context)
else:
widget = wrapper.widget

if widget is not None:
if not is_cpp_wrapper:
if is_python_wrapper:
widget.setToolTip(param.toolTip())

if isinstance(param, QgsProcessingParameterFeatureSource):
@@ -152,7 +148,7 @@ def initWidgets(self):
widget.setLayout(layout)

label = None
if is_cpp_wrapper:
if not is_python_wrapper:
label = wrapper.createWrappedLabel()
else:
label = wrapper.label
@@ -163,7 +159,7 @@ def initWidgets(self):
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, label)
elif not is_cpp_wrapper:
elif is_python_wrapper:
desc = param.description()
if isinstance(param, QgsProcessingParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')

0 comments on commit 8082497

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