mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
[processing] Add possibility to pass additionnal parameters to widget wrapper
This commit is contained in:
parent
2c188b2b0f
commit
482aadc495
@ -178,6 +178,11 @@ class Parameter(object):
|
||||
|
||||
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('.')
|
||||
@ -185,7 +190,7 @@ class Parameter(object):
|
||||
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 @@ class WidgetWrapper(QObject):
|
||||
return v
|
||||
return combobox.currentData()
|
||||
|
||||
def createWidget(self):
|
||||
def createWidget(self, **kwargs):
|
||||
pass
|
||||
|
||||
def setValue(self, value):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user