本文整理汇总了Python中processing.modeler.ModelerParametersDialog.ModelerParametersDialog类的典型用法代码示例。如果您正苦于以下问题:Python ModelerParametersDialog类的具体用法?Python ModelerParametersDialog怎么用?Python ModelerParametersDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModelerParametersDialog类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testModelerParametersDialogAvailableValuesOfType
def testModelerParametersDialogAvailableValuesOfType(self):
# test getAvailableValuesOfType from ModelerParametersDialog
m = QgsProcessingModelAlgorithm()
string_param_1 = QgsProcessingModelParameter('string')
m.addModelParameter(QgsProcessingParameterString('string'), string_param_1)
string_param_2 = QgsProcessingModelParameter('string2')
m.addModelParameter(QgsProcessingParameterString('string2'), string_param_2)
num_param = QgsProcessingModelParameter('number')
m.addModelParameter(QgsProcessingParameterNumber('number'), num_param)
table_field_param = QgsProcessingModelParameter('field')
m.addModelParameter(QgsProcessingParameterField('field'), table_field_param)
file_param = QgsProcessingModelParameter('file')
m.addModelParameter(QgsProcessingParameterFile('file'), file_param)
dlg = ModelerParametersDialog(m, m)
# test single types
self.assertEqual(set(p.parameterName() for p in dlg.getAvailableValuesOfType(QgsProcessingParameterNumber)),
set(['number']))
self.assertEqual(set(p.parameterName() for p in dlg.getAvailableValuesOfType(QgsProcessingParameterField)),
set(['field']))
self.assertEqual(set(p.parameterName() for p in dlg.getAvailableValuesOfType(QgsProcessingParameterFile)),
set(['file']))
# test multiple types
self.assertEqual(set(p.parameterName() for p in dlg.getAvailableValuesOfType([QgsProcessingParameterString, QgsProcessingParameterNumber, QgsProcessingParameterFile])),
set(['string', 'string2', 'number', 'file']))
示例2: __init__
def __init__(self, alg, model, algName=None):
ModelerParametersDialog.__init__(self, alg, model, algName)
paramsLayout = self.paramPanel.layout()
item = paramsLayout.itemAt(paramsLayout.count() - 1)
if isinstance(item, QSpacerItem):
paramsLayout.removeItem(item)
item = None
示例3: setPreviousValues
def setPreviousValues(self):
ModelerParametersDialog.setPreviousValues(self)
if self._algName is not None:
alg = self.model.algs[self._algName]
for param in alg.algorithm.parameters:
if isinstance(param, ParameterFieldsMapping):
widget = self.valueItems[param.name]
value = alg.params[param.name]
if isinstance(value, unicode):
# convert to list because of ModelerAlgorithme.resolveValue behavior with lists
value = eval(value)
widget.setValue(value)
示例4: _addAlgorithm
def _addAlgorithm(self, alg, pos=None):
dlg = ModelerParametersDialog(alg, self.model)
if dlg.exec_():
alg = dlg.createAlgorithm()
if pos is None:
alg.setPosition(self.getPositionForAlgorithmItem())
else:
alg.setPosition(pos)
from processing.modeler.ModelerGraphicItem import ModelerGraphicItem
for i, out in enumerate(alg.modelOutputs()):
alg.modelOutput(out).setPosition(alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, (i + 1.5) *
ModelerGraphicItem.BOX_HEIGHT))
self.model.addChildAlgorithm(alg)
self.repaintModel()
self.hasChanged = True
示例5: _addAlgorithm
def _addAlgorithm(self, alg, pos=None):
dlg = alg.getCustomModelerParametersDialog(self.alg)
if not dlg:
dlg = ModelerParametersDialog(alg, self.alg)
dlg.exec_()
if dlg.alg is not None:
if pos is None:
dlg.alg.pos = self.getPositionForAlgorithmItem()
else:
dlg.alg.pos = pos
if isinstance(dlg.alg.pos, QPoint):
dlg.alg.pos = QPointF(pos)
from processing.modeler.ModelerGraphicItem import ModelerGraphicItem
for i, out in enumerate(dlg.alg.outputs):
dlg.alg.outputs[out].pos = dlg.alg.pos + QPointF(ModelerGraphicItem.BOX_WIDTH, (i + 1.5)
* ModelerGraphicItem.BOX_HEIGHT)
self.alg.addAlgorithm(dlg.alg)
self.repaintModel()
self.hasChanged = True
示例6: _addAlgorithm
def _addAlgorithm(self, alg, pos=None):
dlg = None
try:
dlg = alg.getCustomModelerParametersDialog(self.model)
except:
pass
if not dlg:
dlg = ModelerParametersDialog(alg, self.model)
dlg.exec_()
if dlg.alg is not None:
if pos is None:
dlg.alg.setPosition(self.getPositionForAlgorithmItem())
else:
dlg.alg.setPosition(pos)
from processing.modeler.ModelerGraphicItem import ModelerGraphicItem
for i, out in enumerate(dlg.alg.modelOutputs()):
dlg.alg.modelOutput(out).setPosition(dlg.alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, (i + 1.5) *
ModelerGraphicItem.BOX_HEIGHT))
self.model.addChildAlgorithm(dlg.alg)
self.repaintModel()
self.hasChanged = True
示例7: setParamValue
def setParamValue(self, alg, param, widget):
if isinstance(param, ParameterFieldsMapping):
# convert to unicode because of ModelerAlgorithme.resolveValue behavior with lists
alg.params[param.name] = unicode(widget.value())
return True
return ModelerParametersDialog.setParamValue(self, alg, param, widget)
示例8: getWidgetFromParameter
def getWidgetFromParameter(self, param):
if isinstance(param, ParameterFieldsMapping):
return FieldsMappingPanel()
return ModelerParametersDialog.getWidgetFromParameter(self, param)