本文整理汇总了Python中safe_extras.parameters.qt_widgets.parameter_container.ParameterContainer.add_validator方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterContainer.add_validator方法的具体用法?Python ParameterContainer.add_validator怎么用?Python ParameterContainer.add_validator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_extras.parameters.qt_widgets.parameter_container.ParameterContainer
的用法示例。
在下文中一共展示了ParameterContainer.add_validator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FieldMappingTab
# 需要导入模块: from safe_extras.parameters.qt_widgets.parameter_container import ParameterContainer [as 别名]
# 或者: from safe_extras.parameters.qt_widgets.parameter_container.ParameterContainer import add_validator [as 别名]
#.........这里部分代码省略.........
field['key'], [])
if field['key'] in self.metadata.get('inasafe_fields', {}):
selected_option = FIELDS
if isinstance(custom_fields, basestring):
custom_fields = [custom_fields]
options[FIELDS] = {
'label': field_label,
'value': custom_fields,
'type': MULTIPLE_DYNAMIC,
'constraint': {}
}
used_fields.extend(custom_fields)
parameter = GroupSelectParameter()
parameter.guid = field['key']
parameter.name = field['name']
parameter.options = options
parameter.selected = selected_option
parameter.help_text = field['help_text']
parameter.description = field['description']
self.parameters.append(parameter)
self.parameter_container = ParameterContainer(
parameters=self.parameters,
extra_parameters=self.extra_parameters,
vertical=False
)
self.parameter_container.setup_ui()
constraints = self.field_group.get('constraints', {})
for key, value in constraints.items():
self.parameter_container.add_validator(
validators[key],
kwargs=value['kwargs'],
validation_message=value['message'])
self.parameter_layout.addWidget(self.parameter_container)
# Set move or copy
if self.field_group.get('exclusive', False):
# If exclusive, do not add used field.
self.populate_field_list(excluded_fields=used_fields)
# Use move action since it's exclusive
self.field_list.setDefaultDropAction(Qt.MoveAction)
# Just make sure that the signal is disconnected
try:
# noinspection PyUnresolvedReferences
self.field_list.itemChanged.disconnect(self.drop_remove)
except TypeError:
pass
# Set header
header_text = self.field_group['description']
header_text += '\n\n' + tr(
'You can only map one field to one concept.')
else:
# If not exclusive, add all field.
self.populate_field_list()
# Use copy action since it's not exclusive
self.field_list.setDefaultDropAction(Qt.CopyAction)
# noinspection PyUnresolvedReferences
self.field_list.itemChanged.connect(
partial(self.drop_remove, field_list=self.field_list))
self.connect_drop_remove_parameter()
# Set header