Skip to content

Commit

Permalink
Fix evaluation of Python wrapper values
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 4, 2018
1 parent 70c1680 commit 8082497
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
8 changes: 5 additions & 3 deletions python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/BatchAlgorithmDialog.py
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/processing/gui/BatchPanel.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 6 additions & 10 deletions python/plugins/processing/gui/ParametersPanel.py
Expand Up @@ -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
Expand All @@ -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]\
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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)')
Expand Down

0 comments on commit 8082497

Please sign in to comment.