当前位置: 首页>>代码示例>>Python>>正文


Python parameter_container.ParameterContainer类代码示例

本文整理汇总了Python中parameters.qt_widgets.parameter_container.ParameterContainer的典型用法代码示例。如果您正苦于以下问题:Python ParameterContainer类的具体用法?Python ParameterContainer怎么用?Python ParameterContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ParameterContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    """Main function to run the example."""
    app = QApplication([])

    default_value_parameter = DefaultValueParameter()
    default_value_parameter.name = 'Value parameter'
    default_value_parameter.help_text = 'Help text'
    default_value_parameter.description = 'Description'
    default_value_parameter.labels = [
        'Setting', 'Do not report', 'Custom']
    default_value_parameter.options = [0, 1, None]

    parameters = [
        default_value_parameter
    ]

    extra_parameters = [
        (DefaultValueParameter, DefaultValueParameterWidget)
    ]

    parameter_container = ParameterContainer(
        parameters, extra_parameters=extra_parameters)
    parameter_container.setup_ui()

    widget = QWidget()
    layout = QGridLayout()
    layout.addWidget(parameter_container)

    widget.setLayout(layout)
    widget.setGeometry(0, 0, 500, 500)

    widget.show()

    sys.exit(app.exec_())
开发者ID:akbargumbira,项目名称:inasafe,代码行数:34,代码来源:example.py

示例2: build_minimum_needs_form

    def build_minimum_needs_form(self, parameters):
        """Build minimum needs tab.

        :param parameters: A list containing element of form
        :type parameters: list
        """
        # create minimum needs tab
        scroll_layout = QVBoxLayout()
        scroll_widget = QWidget()
        scroll_widget.setLayout(scroll_layout)
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_widget)
        main_layout = QVBoxLayout()
        main_layout.addWidget(scroll)
        main_widget = QWidget()
        main_widget.setLayout(main_layout)

        extra_parameters = [(ResourceParameter, ResourceParameterWidget)]
        parameter_container = ParameterContainer(
            parameters=parameters, extra_parameters=extra_parameters)
        parameter_container.setup_ui()
        scroll_layout.addWidget(parameter_container)
        self.tabWidget.addTab(main_widget, self.tr('Minimum Needs'))
        self.tabWidget.tabBar().setVisible(True)
        self.values['minimum needs'] = parameter_container.get_parameters
开发者ID:akbargumbira,项目名称:inasafe,代码行数:26,代码来源:function_options_dialog.py

示例3: build_post_processor_form

    def build_post_processor_form(self, form_elements):
        """Build Post Processor Tab.

        :param form_elements: A Dictionary containing element of form.
        :type form_elements: dict
        """
        scroll_layout = QVBoxLayout()
        scroll_widget = QWidget()
        scroll_widget.setLayout(scroll_layout)
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_widget)
        main_layout = QVBoxLayout()
        main_layout.addWidget(scroll)
        main_widget = QWidget()
        main_widget.setLayout(main_layout)

        self.tabWidget.addTab(main_widget, self.tr('Postprocessors'))
        self.tabWidget.tabBar().setVisible(True)

        # create elements for the tab
        values = OrderedDict()
        for label, parameters in form_elements.items():
            parameter_container = ParameterContainer(parameters)
            parameter_container.setup_ui(must_scroll=False)
            scroll_layout.addWidget(parameter_container)
            input_values = parameter_container.get_parameters
            values[label] = input_values

        self.values['postprocessors'] = values
        scroll_layout.addStretch()
开发者ID:akbargumbira,项目名称:inasafe,代码行数:31,代码来源:function_options_dialog.py

示例4: clear

 def clear(self):
     """Clear current state."""
     # Adapted from http://stackoverflow.com/a/13103617/1198772
     for i in reversed(list(range(self.kwExtraKeywordsGridLayout.count()))):
         self.kwExtraKeywordsGridLayout.itemAt(i).widget().setParent(None)
     self.parameters = []
     self.parameter_container = ParameterContainer()
开发者ID:inasafe,项目名称:inasafe,代码行数:7,代码来源:step_kw47_default_inasafe_fields.py

示例5: clear

 def clear(self):
     """Clear current state."""
     # Adapted from http://stackoverflow.com/a/13103617/1198772
     for i in reversed(range(self.default_values_grid.count())):
         self.default_values_grid.itemAt(i).widget().setParent(None)
     self.parameters = []
     self.parameter_container = ParameterContainer()
开发者ID:timlinux,项目名称:inasafe,代码行数:7,代码来源:step_kw49_inasafe_raster_default_values.py

示例6: set_widgets

    def set_widgets(self):
        """Set widgets on the Extra Keywords tab."""
        existing_inasafe_default_values = self.parent.get_existing_keyword(
            'inasafe_default_values')
        # Remove old container and parameter
        if self.parameter_container:
            self.default_values_grid.removeWidget(
                self.parameter_container)
        if self.parameters:
            self.parameters = []

        # Iterate through all inasafe fields
        # existing_inasafe_default_values

        for inasafe_field in self.inasafe_fields_for_the_layer():
            # Create DefaultSelectParameter
            parameter = DefaultValueParameter()
            parameter.guid = inasafe_field['key']
            parameter.name = inasafe_field['name']
            parameter.is_required = False
            parameter.help_text = inasafe_field['default_value']['description']
            # parameter.description = inasafe_field['default_value']
            parameter.element_type = unicode
            parameter.labels = get_inasafe_default_value_fields(
                self.parent.setting, inasafe_field['key'])[0]
            parameter.options = get_inasafe_default_value_fields(
                self.parent.setting, inasafe_field['key'])[1]

            if existing_inasafe_default_values:
                existing_default_value = existing_inasafe_default_values.get(
                    inasafe_field['key'])
                if existing_default_value:
                    parameter.default = existing_default_value

            self.parameters.append(parameter)

        # Create the parameter container and add to the wizard.
        self.parameter_container = ParameterContainer(
            self.parameters, extra_parameters=self.extra_parameters)
        self.parameter_container.setup_ui()
        self.default_values_grid.addWidget(self.parameter_container)

        # Set default value to None
        for parameter_widget in self.parameter_container.\
                get_parameter_widgets():
            parameter_widget.widget().set_value(None)
        # Set default value from existing keywords
        if existing_inasafe_default_values:
            for guid, default in existing_inasafe_default_values.items():
                parameter_widget = self.parameter_container.\
                    get_parameter_widget_by_guid(guid)
                if isinstance(parameter_widget, DefaultValueParameterWidget):
                    parameter_widget.set_value(default)
开发者ID:timlinux,项目名称:inasafe,代码行数:53,代码来源:step_kw49_inasafe_raster_default_values.py

示例7: __init__

    def __init__(self, parent=None):
        """Constructor for the tab.

        :param parent: parent - widget to use as parent (Wizard Dialog).
        :type parent: QWidget

        """
        WizardStep.__init__(self, parent)

        self.parameters = []
        self.parameter_container = ParameterContainer()
        self.kwExtraKeywordsGridLayout.addWidget(self.parameter_container)
开发者ID:akbargumbira,项目名称:inasafe,代码行数:12,代码来源:step_kw45_inasafe_fields.py

示例8: build_widget

    def build_widget(self, form_layout, name, parameter_value):
        """Create a new form element dynamically based from key_value type.

        The Parameter Container will be inserted to form_layout.

        :param form_layout: Mandatory a layout instance
        :type form_layout: QFormLayout

        :param name: Mandatory string referencing the key in the function
         configurable parameters dictionary.
        :type name: str

        :param parameter_value: Mandatory representing the value referenced
        by the key.
        :type parameter_value: object, list

        :returns: a function that return the value of widget

        :raises: None
        """
        input_values = None
        if parameter_value is not None:
            # create and add widget to the dialog box
            # default tab's layout
            parameter_container = ParameterContainer(parameter_value)
            parameter_container.setup_ui(must_scroll=False)
            for w in [w.widget() for w in
                      parameter_container.get_parameter_widgets()]:
                # Rizky : assign error handler for
                # InputListParameterWidget
                w.add_row_error_handler = self.explain_errors
            form_layout.addWidget(parameter_container)
            # bind parameter
            input_values = parameter_container.get_parameters
            self.values[name] = input_values
        else:
            LOGGER.debug('build_widget : parameter is None')
            LOGGER.debug(parameter_value)
        return input_values
开发者ID:akbargumbira,项目名称:inasafe,代码行数:39,代码来源:function_options_dialog.py

示例9: __init__

    def __init__(self, parameter, parent=None):
        """Constructor

        .. versionadded:: 2.2

        :param parameter: A GroupParameter object.
        :type parameter: GroupParameter

        """
        super().__init__(parameter, parent)

        # Get the parameter label and use its value as the checkbox text
        label_item = self.input_layout.itemAt(0)
        label_widget = label_item.widget()
        text = label_widget.text()
        self._enable_check_box = QCheckBox(text)
        # Tooltips
        self.setToolTip('Tick here to enable ' + self._parameter.name)

        # add all widget in the group
        self._group_layout = QVBoxLayout()
        self._group_layout.setSpacing(0)

        if not self._parameter.is_required:
            self.input_layout.insertWidget(0, self._enable_check_box)
            # now we don't need the parameter label anymore so chuck it
            self.input_layout.removeItem(label_item)
            # Make the sub group appear indented
            self._group_layout.setContentsMargins(20, 0, 0, 0)
        else:
            self._parameter.enable_parameter = True

        self.main_layout.addLayout(self._group_layout)

        # Why are we doing imports here? TS
        from parameters.qt_widgets.parameter_container import (
            ParameterContainer)

        self.param_container = ParameterContainer(
            parameters=self._parameter.value)
        self.param_container.setup_ui(must_scroll=parameter.must_scroll)

        # add handlers
        # noinspection PyUnresolvedReferences
        self._enable_check_box.stateChanged.connect(
            self.on_enable_checkbox_changed)
        self._enable_check_box.setChecked(self._parameter.enable_parameter)
        self.on_enable_checkbox_changed(self._parameter.enable_parameter)

        self._group_layout.addWidget(self.param_container)
开发者ID:inasafe,项目名称:parameters,代码行数:50,代码来源:group_parameter_widget.py

示例10: __init__

    def __init__(self, parent=None):
        """Constructor for the tab.

        :param parent: parent - widget to use as parent (Wizard Dialog).
        :type parent: QWidget
        """
        WizardStep.__init__(self, parent)

        self.extra_parameters = [
            (DefaultValueParameter, DefaultValueParameterWidget)
        ]
        self.parameters = []
        self.parameter_container = ParameterContainer(
            extra_parameters=self.extra_parameters)
        self.default_values_grid.addWidget(self.parameter_container)
开发者ID:timlinux,项目名称:inasafe,代码行数:15,代码来源:step_kw49_inasafe_raster_default_values.py

示例11: __init__

    def __init__(self, parent=None):
        """Constructor for the tab.

        :param parent: parent - widget to use as parent (Wizard Dialog).
        :type parent: QWidget

        """
        WizardStep.__init__(self, parent)

        self.extra_parameters = [
            (DefaultSelectParameter, DefaultSelectParameterWidget)
        ]
        self.parameters = []
        self.parameter_container = ParameterContainer(
            extra_parameters=self.extra_parameters)
        self.kwExtraKeywordsGridLayout.addWidget(self.parameter_container)
        self.message_label = QLabel()
开发者ID:inasafe,项目名称:inasafe,代码行数:17,代码来源:step_kw47_default_inasafe_fields.py

示例12: set_widgets

    def set_widgets(self):
        """Set widgets on the Extra Keywords tab."""
        existing_inasafe_field = self.parent.get_existing_keyword(
            'inasafe_fields')
        # Remove old container and parameter
        if self.parameter_container:
            self.kwExtraKeywordsGridLayout.removeWidget(
                self.parameter_container)
        if self.parameters:
            self.parameters = []

        layer_data_provider = self.parent.layer.dataProvider()

        # Iterate through all inasafe fields
        for inasafe_field in self.inasafe_fields_for_the_layer():
            # Option for Not Available
            option_list = [no_field]
            for field in layer_data_provider.fields():
                # Check the field type
                if isinstance(inasafe_field['type'], list):
                    if field.type() in inasafe_field['type']:
                        field_name = field.name()
                        option_list.append('%s' % field_name)
                else:
                    if field.type() == inasafe_field['type']:
                        field_name = field.name()
                        option_list.append('%s' % field_name)

            # If there is no option, pass
            if option_list == [no_field]:
                continue

            # Create SelectParameter
            select_parameter = SelectParameter()
            select_parameter.guid = inasafe_field['key']
            select_parameter.name = inasafe_field['name']
            select_parameter.is_required = False
            select_parameter.description = inasafe_field['description']
            select_parameter.help_text = inasafe_field['help_text']
            select_parameter.element_type = unicode
            select_parameter.options_list = option_list
            select_parameter.value = no_field
            # Check if there is already value in the metadata.
            if existing_inasafe_field:
                existing_value = existing_inasafe_field.get(
                    inasafe_field['key'])
                if existing_value:
                    if existing_value in select_parameter.options_list:
                        select_parameter.value = existing_value

            self.parameters.append(select_parameter)

        # Create the parameter container and add to the wizard.
        self.parameter_container = ParameterContainer(self.parameters)
        self.parameter_container.setup_ui()
        self.kwExtraKeywordsGridLayout.addWidget(self.parameter_container)

        if not self.parameters:
            no_field_message = tr(
                'There is no available field that has match type for the '
                'InaSAFE fields. You can click next.')
            self.lblInaSAFEFields.setText(no_field_message)
开发者ID:akbargumbira,项目名称:inasafe,代码行数:62,代码来源:step_kw45_inasafe_fields.py

示例13: populate_parameter

    def populate_parameter(self):
        """Helper to setup the parameter widget."""
        used_fields = []
        self.parameters = []
        for field in self.field_group.get('fields', []):
            selected_option = DO_NOT_REPORT
            options = OrderedDict([
                (DO_NOT_REPORT,
                 {
                     'label': tr('Do not report'),
                     'value': None,
                     'type': STATIC,
                     'constraint': {}
                 }),
            ])

            # Example: count
            if field['absolute']:
                # Used in field options
                field_label = tr('Count fields')
            else:  # Example: ratio
                # Used in field options
                field_label = tr('Ratio fields')
                global_default_value = get_inasafe_default_value_qsetting(
                    self.setting, GLOBAL, field['key'])
                options[GLOBAL_DEFAULT] = {
                    'label': tr('Global default'),
                    'value': global_default_value,
                    'type': STATIC,
                    'constraint': {}
                }
                default_custom_value = get_inasafe_default_value_qsetting(
                    self.setting, RECENT, field['key'])
                custom_value = self.metadata.get(
                    'inasafe_default_values', {}).get(
                    field['key'], default_custom_value)
                if field['key'] in self.metadata.get(
                        'inasafe_default_values', {}):
                    if custom_value == global_default_value:
                        selected_option = GLOBAL_DEFAULT
                    else:
                        selected_option = CUSTOM_VALUE
                min_value = field['default_value'].get('min_value', 0)
                max_value = field['default_value'].get('max_value', 100)
                default_step = (max_value - min_value) / 100.0
                step = field['default_value'].get('increment', default_step)
                options[CUSTOM_VALUE] = {
                    'label': tr('Custom'),
                    'value': custom_value,
                    'type': SINGLE_DYNAMIC,
                    'constraint': {
                        'min': min_value,
                        'max': max_value,
                        'step': step
                    }
                }

            custom_fields = self.metadata.get('inasafe_fields', {}).get(
                field['key'], [])
            if field['key'] in self.metadata.get('inasafe_fields', {}):
                selected_option = FIELDS
            if isinstance(custom_fields, str):
                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 list(constraints.items()):
            self.parameter_container.add_validator(
                validators[key],
                kwargs=value['kwargs'],
                validation_message=value['message'])

        self.parameter_layout.addWidget(self.parameter_container)

        default_ratio_help_text = tr(
            'By default, InaSAFE will calculate the default ratio '
#.........这里部分代码省略.........
开发者ID:inasafe,项目名称:inasafe,代码行数:101,代码来源:field_mapping_tab.py

示例14: FieldMappingTab


#.........这里部分代码省略.........
                    'value': custom_value,
                    'type': SINGLE_DYNAMIC,
                    'constraint': {
                        'min': min_value,
                        'max': max_value,
                        'step': step
                    }
                }

            custom_fields = self.metadata.get('inasafe_fields', {}).get(
                field['key'], [])
            if field['key'] in self.metadata.get('inasafe_fields', {}):
                selected_option = FIELDS
            if isinstance(custom_fields, str):
                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 list(constraints.items()):
            self.parameter_container.add_validator(
                validators[key],
                kwargs=value['kwargs'],
                validation_message=value['message'])

        self.parameter_layout.addWidget(self.parameter_container)

        default_ratio_help_text = tr(
            'By default, InaSAFE will calculate the default ratio '
            'however users have the option to include this in the '
            'analysis report. If you do not want to see the default '
            'results in the report choose "do not report".')
        # 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:
开发者ID:inasafe,项目名称:inasafe,代码行数:67,代码来源:field_mapping_tab.py

示例15: main

def main():
    """Main function"""
    app = QApplication([])

    def validate_min_max(parent_container):
        """
        :param parent_container: The container that use this validator.
        :type parent_container: ParameterContainer
        :return:
        """
        min_value_parameter = parent_container.get_parameter_by_guid(
            min_integer_parameter.guid)
        max_value_parameter = parent_container.get_parameter_by_guid(
            max_integer_parameter.guid)

        min_value = min_value_parameter.value
        max_value = max_value_parameter.value

        print('min', min_value)
        print('max', max_value)

        if min_value > max_value:
            print('Not valid')
            message = ('Your minimum value (%d) should be less than your '
                       'maximum value (%d)' % (min_value, max_value))
            return {
                'valid': False,
                'message': message
            }
        print('Valid')
        return {'valid': True, 'message': ''}

    unit_feet = Unit('130790')
    unit_feet.load_dictionary(unit_feet_depth)

    unit_metres = Unit('900713')
    unit_metres.load_dictionary(unit_metres_depth)

    string_parameter = StringParameter('28082014')
    string_parameter.name = 'Province Name'
    string_parameter.description = 'Name of province.'
    string_parameter.help_text = (
        'A <b>test help</b> that is very long so that you need to '
        'read it for one minute and you will be tired after read this '
        'description. You are the best user so far. Even better if you read '
        'this description loudly so that all of your friends will be able '
        'to hear you')
    string_parameter.is_required = True
    string_parameter.value = 'Daerah Istimewa Yogyakarta'

    boolean_parameter = BooleanParameter('1231231')
    boolean_parameter.name = 'Post processor'
    boolean_parameter.description = 'This is post processor parameter.'
    boolean_parameter.help_text = (
        'A <b>test help text</b> that is very long so that you need to '
        'read it for one minute and you will be tired after read this '
        'description. You are the best user so far. Even better if you read '
        'this description loudly so that all of your friends will be able '
        'to hear you')
    boolean_parameter.is_required = True
    boolean_parameter.value = True

    float_parameter = FloatParameter()
    float_parameter.name = 'Flood Depth'
    float_parameter.is_required = True
    float_parameter.precision = 3
    float_parameter.minimum_allowed_value = 1.0
    float_parameter.maximum_allowed_value = 2.0
    float_parameter.description = 'The depth of flood.'
    float_parameter.help_text = (
        'A <b>test _description</b> that is very long so that you need to '
        'read it for one minute and you will be tired after read this '
        'description. You are the best user so far. Even better if you read '
        'this description loudly so that all of your friends will be able '
        'to hear you')
    float_parameter.unit = unit_feet
    float_parameter.allowed_units = [unit_metres, unit_feet]
    float_parameter.value = 1.12

    integer_parameter = IntegerParameter()
    integer_parameter.name = 'Paper'
    integer_parameter.is_required = True
    integer_parameter.minimum_allowed_value = 1
    integer_parameter.maximum_allowed_value = 5
    integer_parameter.description = 'Number of paper'
    integer_parameter.help_text = (
        'A <b>test _description</b> that is very long so that you need to '
        'read it for one minute and you will be tired after read this '
        'description. You are the best user so far. Even better if you read '
        'this description loudly so that all of your friends will be able '
        'to hear you')
    integer_parameter.unit = unit_feet
    integer_parameter.allowed_units = [unit_feet]
    integer_parameter.value = 3

    point_parameter = PointParameter()
    point_parameter.name = 'Point Parameter'
    point_parameter.is_required = True
    point_parameter.description = 'Short help.'
    point_parameter.help_text = 'Long description for parameter.'
#.........这里部分代码省略.........
开发者ID:inasafe,项目名称:parameters,代码行数:101,代码来源:main.py


注:本文中的parameters.qt_widgets.parameter_container.ParameterContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。