Skip to content
Permalink
Browse files

[processing] Add possibility to pass additionnal parameters to widget…

… wrapper
  • Loading branch information
arnaud-morvan committed Feb 9, 2017
1 parent 2c188b2 commit 482aadc495daae625c69b0b632ec3e67b038cc24
Showing with 10 additions and 7 deletions.
  1. +6 −1 python/plugins/processing/core/parameters.py
  2. +4 −6 python/plugins/processing/gui/wrappers.py
@@ -178,14 +178,19 @@ def tr(self, string, context=''):

def wrapper(self, dialog, row=0, col=0):
wrapper = self.metadata.get('widget_wrapper', None)
params = {}
# wrapper metadata should be a dict with class key
if isinstance(wrapper, dict):
params = deepcopy(wrapper)
wrapper = params.pop('class')
# wrapper metadata should be a class path
if isinstance(wrapper, str):
tokens = wrapper.split('.')
mod = __import__('.'.join(tokens[:-1]), fromlist=[tokens[-1]])
wrapper = getattr(mod, tokens[-1])
# or directly a class object
if isclass(wrapper):
wrapper = wrapper(self, dialog, row, col)
wrapper = wrapper(self, dialog, row, col, **params)
# or a wrapper instance
return wrapper

@@ -2,7 +2,7 @@

"""
***************************************************************************
wrappers.py
wrappers.py - Standard parameters widget wrappers
---------------------
Date : May 2016
Copyright : (C) 2016 by Arnaud Morvan, Victor Olaya
@@ -17,8 +17,6 @@
* *
***************************************************************************
"""
from builtins import str
from builtins import range


__author__ = 'Arnaud Morvan'
@@ -101,14 +99,14 @@ class WidgetWrapper(QObject):

widgetValueHasChanged = pyqtSignal(object)

def __init__(self, param, dialog, row=0, col=0):
def __init__(self, param, dialog, row=0, col=0, **kwargs):
QObject.__init__(self)
self.param = param
self.dialog = dialog
self.row = row
self.col = col
self.dialogType = dialogTypes.get(dialog.__class__.__name__, DIALOG_STANDARD)
self.widget = self.createWidget()
self.widget = self.createWidget(**kwargs)
if param.default is not None:
self.setValue(param.default)

@@ -123,7 +121,7 @@ def comboValue(self, validator=None, combobox=None):
return v
return combobox.currentData()

def createWidget(self):
def createWidget(self, **kwargs):
pass

def setValue(self, value):

0 comments on commit 482aadc

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