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


Python QButtonGroup.checkedId方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QButtonGroup.checkedId方法的典型用法代码示例。如果您正苦于以下问题:Python QButtonGroup.checkedId方法的具体用法?Python QButtonGroup.checkedId怎么用?Python QButtonGroup.checkedId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QButtonGroup的用法示例。


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

示例1: RadioBooleanFilter

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class RadioBooleanFilter(QWidget, Control):

    """ Boolean filter (Only/Exclude)
    """

    def __init__(self, tree, dataset, master, parent=None):
        QWidget.__init__(self, parent)
        Control.__init__(self, tree, dataset, master)

        self.setLayout(QVBoxLayout())
        self.buttonGroup = QButtonGroup(self)
        self.values = []
        for i, option in enumerate(tree.subelements_top("Option")):
            rb = QRadioButton(option.displayName, self)
            self.buttonGroup.addButton(rb)
            self.buttonGroup.setId(rb, i)
            self.layout().addWidget(rb)
            self.values.append(option.value)
        self.buttonGroup.button(0).setChecked(True)

    def value(self):
        return {"excluded": "%i" % self.buttonGroup.checkedId()}

    def get_filter(self):
        return self.tree.internalName, self.value()

    def query(self):
        return [("Filter", self.tree, self.value())]

    def setControlValue(self, name, value):
        for i, v in enumerate(self.values):
            if v == value:
                button = self.buttonGroup.button(i)
                button.setChecked(True)
                break
开发者ID:nagyistoce,项目名称:orange-bio,代码行数:37,代码来源:OWBioMart.py

示例2: TokenizerModule

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class TokenizerModule(PreprocessorModule):
    DEFAULT_SETTINGS = {
        'is_enabled': True,
        'method': 0,
    }

    NLTKTokenizer, NLTKPunctTokenizer, TwitterTokenizer = 0, 1, 2
    tokenizer_values = {
        NLTKTokenizer: 'default',
        NLTKPunctTokenizer: 'no_punct',
        TwitterTokenizer: 'twitter'
    }
    tokenizer_names = {
        NLTKTokenizer: 'NLTK tokenizer',
        NLTKPunctTokenizer: 'NLTK tokenizer (no punctuation)',
        TwitterTokenizer: 'Twitter tokenizer',
    }

    tokenizer_method = 0

    def __init__(self, data):
        data = data or self.DEFAULT_SETTINGS
        PreprocessorModule.__init__(
                self, 'Tokenizer', False,
                data.get('is_enabled')
        )

        self.group = QButtonGroup(self, exclusive=True)
        for method in [
            self.NLTKTokenizer,
            self.NLTKPunctTokenizer,
            self.TwitterTokenizer,
        ]:
            rb = QRadioButton(self, text=self.tokenizer_names[method])
            self.add_to_content_area(rb)
            self.group.addButton(rb, method)
        self.group.buttonClicked.connect(self.group_button_clicked)

        # Restore the previous state, after starting off the layout.
        self.restore_data(data)

    def group_button_clicked(self):
        self.tokenizer_method = self.group.checkedId()
        self.notify_on_change()

    def restore_data(self, data):
        self.tokenizer_method = data.get('method')
        b = self.group.button(self.tokenizer_method)
        b.setChecked(True)

    def export_data(self):
        return {
            'is_enabled': self.enabled,
            'method': self.tokenizer_method,
        }

    def get_pp_setting(self):
        return {
            'tokenizer': self.tokenizer_values.get(self.tokenizer_method)
        }
开发者ID:david-novak,项目名称:orange3-text,代码行数:62,代码来源:owpreprocess.py

示例3: choice

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
    def choice(self, title, msg, choices):
        vbox = QVBoxLayout()
        self.set_layout(vbox)
        vbox.addWidget(QLabel(title))
        gb2 = QGroupBox(msg)
        vbox.addWidget(gb2)

        vbox2 = QVBoxLayout()
        gb2.setLayout(vbox2)

        group2 = QButtonGroup()
        for i, c in enumerate(choices):
            button = QRadioButton(gb2)
            button.setText(c[1])
            vbox2.addWidget(button)
            group2.addButton(button)
            group2.setId(button, i)
            if i == 0:
                button.setChecked(True)
        vbox.addStretch(1)
        vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next'))))
        if not self.exec_():
            return
        wallet_type = choices[group2.checkedId()][0]
        return wallet_type
开发者ID:gjhiggins,项目名称:electrum,代码行数:27,代码来源:installwizard.py

示例4: TransformationModule

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class TransformationModule(PreprocessorModule):
    DEFAULT_SETTINGS = {
        'is_enabled': True,
        'method': 0,
    }

    PorterStemmer, SnowballStemmer, Lemmatizer = 0, 1, 2
    transformation_values = {
        PorterStemmer: PS,
        SnowballStemmer: SS,
        Lemmatizer: LM,
    }

    transformation_method = 0

    def __init__(self, data):
        data = data or self.DEFAULT_SETTINGS
        PreprocessorModule.__init__(
                self, 'Stemming', True,
                data.get('is_enabled')
        )

        self.group = QButtonGroup(self, exclusive=True)
        for method in [
            self.PorterStemmer,
            self.SnowballStemmer,
            self.Lemmatizer
        ]:
            rb = QRadioButton(
                    self,
                    text=self.transformation_values[method].name
            )
            self.add_to_content_area(rb)
            self.group.addButton(rb, method)
        self.group.buttonClicked.connect(self.group_button_clicked)

        # Restore the previous state, after starting off the layout.
        self.restore_data(data)

    def group_button_clicked(self):
        self.transformation_method = self.group.checkedId()
        self.notify_on_change()

    def restore_data(self, data):
        self.transformation_method = data.get('method')
        b = self.group.button(self.transformation_method)
        b.setChecked(True)

    def export_data(self):
        return {
            'is_enabled': self.enabled,
            'method': self.transformation_method,
        }

    def get_pp_setting(self):
        return {
            'transformation': self.transformation_values.get(
                    self.transformation_method
            )
        }
开发者ID:david-novak,项目名称:orange3-text,代码行数:62,代码来源:owpreprocess.py

示例5: ScopeBox

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class ScopeBox(QGroupBox):
    title = None
    button_type = None

    def __init__(self):
        if self.title is None or self.button_type is None:
            raise Exception("Still too abstract!")

        super().__init__(title=self.title)

        self.populate_button_id()
        self.build_layout()
        self.populate_box()
        self.select_default()

        if self.button_type == 'check':
            self.group.setExclusive(False)

    def populate_button_id(self):
        pass

    def build_layout(self):
        self.group = QButtonGroup()
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

    def populate_box(self):
        keys = list(self.button_id.keys())
        keys.sort()

        BtnClass = None
        if self.button_type == 'check':
            BtnClass = QCheckBox
        elif self.button_type == 'radio':
            BtnClass = QRadioButton

        for key in keys:
            btn = BtnClass(key)
            self.layout.addWidget(btn)
            self.group.addButton(btn, self.button_id[key])

    def select_default(self):
        pass

    def getSelection(self):
        selection = None

        if self.button_type == 'radio':
            selection = self.group.checkedId()
        elif self.button_type == 'check':
            selection = []

            for btn in self.group.buttons():
                if btn.isChecked():
                    selection.append(btn.text())

        return selection
开发者ID:Atlantic777,项目名称:perf_test_runner,代码行数:59,代码来源:widgets.py

示例6: SingleMethodModule

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class SingleMethodModule(PreprocessorModule):
    method_index = settings.Setting(0)
    initialize_methods = True

    def setup_method_layout(self):
        self.group = QButtonGroup(self, exclusive=True)

        if self.initialize_methods:
            self.methods = [method() for method in self.methods]

        for i, method in enumerate(self.methods):
            rb = QRadioButton(self, text=self.textify(method.name))
            rb.setChecked(i == self.method_index)
            rb.setToolTip(self.get_tooltip(method))
            self.group.addButton(rb, i)
            self.method_layout.addWidget(rb, i, 0)

        self.group.buttonClicked.connect(self.update_value)

    def get_value(self):
        self.method_index = self.group.checkedId()
        return self.methods[self.method_index]
开发者ID:nikicc,项目名称:orange3-text,代码行数:24,代码来源:owpreprocess.py

示例7: InterpolateConfirmDialog

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class InterpolateConfirmDialog(QDialog):
    """
    Dialog class to confirm the interpolation
    """

    def __init__(self):
        """
        Constructor
        """
        QDialog.__init__(self)
        self.setWindowTitle(QCoreApplication.translate("VDLTools", "Edition Confirmation"))
        self.__layout = QGridLayout()

        self.__confirmLabel = QLabel(
            QCoreApplication.translate("VDLTools", "This LineString layer is not editable, what do you want to do ?"))

        self.__layout.addWidget(self.__confirmLabel, 0, 0, 1, 2)

        self.__radios = []

        self.__radios.append(QRadioButton(
            QCoreApplication.translate("VDLTools", "Create point, and edit line with new vertex")))
        self.__radios.append(QRadioButton(QCoreApplication.translate("VDLTools", "Create only the point")))
        self.__radios.append(QRadioButton(QCoreApplication.translate("VDLTools", "Just edit line with new vertex")))

        self.__scrollLayout = QGridLayout()

        self.__radios[0].setChecked(True)
        self.__radio_button_group = QButtonGroup()
        for i in range(len(self.__radios)):
            self.__scrollLayout.addWidget(self.__radios[i], i+1, 0, 1, 2)
            self.__radio_button_group.addButton(self.__radios[i], i)

        widget = QWidget()
        widget.setLayout(self.__scrollLayout)

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setWidget(widget)

        self.__layout.addWidget(scroll, 1, 0, 1, 2)

        self.__okButton = QPushButton(QCoreApplication.translate("VDLTools", "OK"))
        self.__okButton.setMinimumHeight(20)
        self.__okButton.setMinimumWidth(100)

        self.__layout.addWidget(self.__okButton, 4, 0)

        self.__cancelButton = QPushButton(QCoreApplication.translate("VDLTools", "Cancel"))
        self.__cancelButton.setMinimumHeight(20)
        self.__cancelButton.setMinimumWidth(100)

        self.__layout.addWidget(self.__cancelButton, 4, 1)

        self.setLayout(self.__layout)

    def setMainLabel(self, label):
        """
        To set the title
        :param label: title
        """
        self.__confirmLabel.setText(label)

    def setAllLabel(self, label):
        """
        To set the all button title
        :param label: title
        """
        self.__radios[0].setText(label)

    def setVtLabel(self, label):
        """
        To set the vertex button title
        :param label: title
        """
        self.__radios[2].setText(label)

    def getCheckedId(self):
        """
        To get the radio button checked id
        0 : all
        1 : point
        2 : vertex
        :return: id of radion button
        """
        return self.__radio_button_group.checkedId()

    def okButton(self):
        """
        To get the ok button instance
        :return: ok button instance
        """
        return self.__okButton

    def cancelButton(self):
        """
        To get the cancel button instance
        :return: cancel button instance
        """
        return self.__cancelButton
开发者ID:gusthiot,项目名称:VDLTools,代码行数:102,代码来源:interpolate_confirm_dialog.py

示例8: DefaultSelectParameterWidget

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]

#.........这里部分代码省略.........

        # check every added combobox, it could have been toggled by
        # the existing keyword
        self.toggle_input()

        # Connect
        # noinspection PyUnresolvedReferences
        self.input.currentIndexChanged.connect(self.toggle_input)
        self.default_input_button_group.buttonClicked.connect(
            self.toggle_custom_value)

    def raise_invalid_type_exception(self):
        message = 'Expecting element type of %s' % (
            self._parameter.element_type.__name__)
        err = ValueError(message)
        return err

    def get_parameter(self):
        """Obtain list parameter object from the current widget state.

        :returns: A DefaultSelectParameter from the current state of widget.
        """
        current_index = self.input.currentIndex()
        selected_value = self.input.itemData(current_index, Qt.UserRole)
        if hasattr(selected_value, 'toPyObject'):
            selected_value = selected_value.toPyObject()

        try:
            self._parameter.value = selected_value
        except ValueError:
            err = self.raise_invalid_type_exception()
            raise err

        radio_button_checked_id = self.default_input_button_group.checkedId()
        # No radio button checked, then default value = None
        if radio_button_checked_id == -1:
            self._parameter.default = None
        # The last radio button (custom) is checked, get the value from the
        # line edit
        elif (radio_button_checked_id ==
                len(self._parameter.default_values) - 1):
            self._parameter.default_values[radio_button_checked_id] \
                = self.custom_value.value()
            self._parameter.default = self.custom_value.value()
        else:
            self._parameter.default = self._parameter.default_values[
                radio_button_checked_id]

        return self._parameter

    def set_default(self, default):
        """Set default value by item's string.

        :param default: The default.
        :type default: str, int

        :returns: True if success, else False.
        :rtype: bool
        """
        # Find index of choice
        try:
            default_index = self._parameter.default_values.index(default)
            self.default_input_button_group.button(default_index).setChecked(
                True)
        except ValueError:
            last_index = len(self._parameter.default_values) - 1
开发者ID:timlinux,项目名称:inasafe,代码行数:70,代码来源:default_select_parameter_widget.py

示例9: GroupSelectParameterWidget

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]

#.........这里部分代码省略.........
        self.help_layout = QVBoxLayout()
        self.help_layout.addWidget(self.help_label)

        self.main_layout.addLayout(self.input_layout)
        self.main_layout.addLayout(self.help_layout)

        self.setLayout(self.main_layout)

        self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding)

        # Update list widget
        self.update_list_widget()

        # Connect signal
        self.input_button_group.buttonClicked.connect(
            self.radio_buttons_clicked)

    def get_parameter(self):
        """Obtain list parameter object from the current widget state.

        :returns: A DefaultValueParameter from the current state of widget
        :rtype: DefaultValueParameter
        """
        # Set value for each key
        for key, value in self._parameter.options.items():
            if value.get('type') == STATIC:
                continue
            elif value.get('type') == SINGLE_DYNAMIC:
                new_value = self.spin_boxes.get(key).value()
                self._parameter.set_value_for_key(key, new_value)
            elif value.get('type') == MULTIPLE_DYNAMIC:
                # Need to iterate through all items
                items = []
                for index in xrange(self.list_widget.count()):
                    items.append(self.list_widget.item(index))
                new_value = [i.text() for i in items]
                self._parameter.set_value_for_key(key, new_value)

        # Get selected radio button
        radio_button_checked_id = self.input_button_group.checkedId()
        # No radio button checked, then default value = None
        if radio_button_checked_id == -1:
            self._parameter.selected = None
        else:
            self._parameter.selected = self._parameter.options.keys()[
                radio_button_checked_id]

        return self._parameter

    def update_list_widget(self):
        """Update list widget when radio button is clicked."""
        # Get selected radio button
        radio_button_checked_id = self.input_button_group.checkedId()
        # No radio button checked, then default value = None
        if radio_button_checked_id > -1:
            selected_dict = self._parameter.options.values()[
                radio_button_checked_id]
            if selected_dict.get('type') == MULTIPLE_DYNAMIC:
                for field in selected_dict.get('value'):
                    # Update list widget
                    field_item = QListWidgetItem(self.list_widget)
                    field_item.setFlags(
                        Qt.ItemIsEnabled |
                        Qt.ItemIsSelectable |
                        Qt.ItemIsDragEnabled)
                    field_item.setData(Qt.UserRole, field)
                    field_item.setText(field)
                    self.list_widget.addItem(field_item)

    def radio_buttons_clicked(self):
        """Handler when selected radio button changed."""
        # Disable all spin boxes
        for spin_box in self.spin_boxes.values():
            spin_box.setEnabled(False)
        # Disable list widget
        self.list_widget.setEnabled(False)

        # Get selected radio button
        radio_button_checked_id = self.input_button_group.checkedId()

        if radio_button_checked_id > -1:
            selected_value = self._parameter.options.values()[
                radio_button_checked_id]
            if selected_value.get('type') == MULTIPLE_DYNAMIC:
                # Enable list widget
                self.list_widget.setEnabled(True)
            elif selected_value.get('type') == SINGLE_DYNAMIC:
                selected_key = self._parameter.options.keys()[
                    radio_button_checked_id]
                self.spin_boxes[selected_key].setEnabled(True)

    def select_radio_button(self, key):
        """Helper to select a radio button with key.

        :param key: The key of the radio button.
        :type key: str
        """
        key_index = self._parameter.options.keys().index(key)
        radio_button = self.input_button_group.button(key_index)
        radio_button.click()
开发者ID:timlinux,项目名称:inasafe,代码行数:104,代码来源:group_select_parameter_widget.py

示例10: MainWindow

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]

#.........这里部分代码省略.........
            self.dcm_offsetmm = data['offsetmm'] 
            self.setVoxelVolume(self.voxel_sizemm.reshape((3,)))
            self.setLabelText(self.text_mesh_in, filename)
            self.statusBar().showMessage('Ready')
            
        else:
            self.statusBar().showMessage('No input file specified!')

    def saveMesh(self, event=None, filename=None):
        if self.mesh_data is not None:
            self.statusBar().showMessage('Saving mesh...')
            QApplication.processEvents()

            if filename is None:
                file_ext = inv_supported_formats[self.mesh_out_format]
                filename = str(QFileDialog.getSaveFileName(self, 'Save MESH file',
                                                           filter='Files (*%s)' % file_ext))

            if len(filename) > 0:

                io = MeshIO.for_format(filename, format=self.mesh_out_format, writable=True)
                io.write(filename, self.mesh_data)

                self.setLabelText(self.text_mesh_out, filename)
                self.statusBar().showMessage('Ready')
            
            else:
                self.statusBar().showMessage('No output file specified!')

        else:
            self.statusBar().showMessage('No mesh data!')

    def generMesh(self):
        from seg2fem import gen_mesh_from_voxels

        etab = {1: 't', 2: 'q'}
        mtab = {1: 's', 2: 'v'}

        eid = self.rbtng_mesh_elements.checkedId()
        mid = self.rbtng_mesh_mesh.checkedId()
        self.statusBar().showMessage('Generating mesh...')
        QApplication.processEvents()
        
        self.mesh_data = gen_mesh_from_voxels(self.segmentation_data,
                                              self.voxel_sizemm * 1.0e-3,
                                              etype=etab[eid],
                                              mtype=mtab[mid])
        self.mesh_data.coors += self.dcm_offsetmm.reshape((1,3)) * 1.0e-3
        
        self.setLabelText(self.text_mesh_data, '%d %s'\
                          % (self.mesh_data.n_el,
                             elem_tab[self.mesh_data.descs[0]]))

        self.statusBar().showMessage('Ready')

    def smoothMesh(self):
        from seg2fem import gen_mesh_from_voxels_mc, smooth_mesh

        self.statusBar().showMessage('Smoothing mesh...')
        QApplication.processEvents()

        if self.mesh_smooth_method == 'marching cubes':
            self.mesh_data = gen_mesh_from_voxels_mc(self.segmentation_data,
                                                     self.voxel_sizemm * 1.0e-3)
            self.mesh_data.coors += self.dcm_offsetmm.reshape((1,3)) * 1.0e-3

        elif self.mesh_smooth_method == 'taubin':
            mid = self.rbtng_mesh_mesh.checkedId()
            if mid == 'v':
                 volume_corr=True

            else:
                volume_corr=False

            self.mesh_data.coors = smooth_mesh(self.mesh_data,
                                               n_iter=10, lam=0.6307, mu=-0.6347,
                                               volume_corr=volume_corr)
            
        self.setLabelText(self.text_mesh_data, '%d %s, smooth method - %s'\
                          % (self.mesh_data.n_el,
                             elem_tab[self.mesh_data.descs[0]],
                              self.mesh_smooth_method))

        self.statusBar().showMessage('Ready')
    
    def viewMesh(self):
        if self.mesh_data is not None:
            vtk_file = 'mesh_geom.vtk'
            self.mesh_data.write(vtk_file)
            view = QVTKViewer(vtk_file)
            view.exec_()

        else:
            self.statusBar().showMessage('No mesh data!')

    def changeOut(self, val):
        self.mesh_out_format = str(val)

    def changeSmoothMethod(self, val):
        self.mesh_smooth_method = str(val)
开发者ID:rc,项目名称:dicom2fem,代码行数:104,代码来源:dicom2fem.py

示例11: restore_or_create

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
    def restore_or_create(self):
        vbox = QVBoxLayout()

        main_label = QLabel(_("Electrum-VCN could not find an existing wallet."))
        vbox.addWidget(main_label)

        grid = QGridLayout()
        grid.setSpacing(5)

        gb1 = QGroupBox(_("What do you want to do?"))
        vbox.addWidget(gb1)
        vbox1 = QVBoxLayout()
        gb1.setLayout(vbox1)

        b1 = QRadioButton(gb1)
        b1.setText(_("Create new wallet"))
        b1.setChecked(True)

        b2 = QRadioButton(gb1)
        b2.setText(_("Restore a wallet or import keys"))

        group1 = QButtonGroup()
        group1.addButton(b1)
        group1.addButton(b2)
        vbox1.addWidget(b1)
        vbox1.addWidget(b2)

        gb2 = QGroupBox(_("Wallet type:"))
        vbox.addWidget(gb2)

        vbox2 = QVBoxLayout()
        gb2.setLayout(vbox2)

        group2 = QButtonGroup()

        self.wallet_types = [
            ('standard', _("Standard wallet")),
            ('twofactor', _("Wallet with two-factor authentication")),
            ('multisig', _("Multi-signature wallet")),
            ('hardware', _("Hardware wallet")),
        ]

        for i, (wtype, name) in enumerate(self.wallet_types):
            if not filter(lambda x: x[0] == wtype, electrum.wallet.wallet_types):
                continue
            button = QRadioButton(gb2)
            button.setText(name)
            vbox2.addWidget(button)
            group2.addButton(button)
            group2.setId(button, i)

            if i == 0:
                button.setChecked(True)

        vbox.addStretch(1)
        self.set_layout(vbox)
        vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next'))))
        self.show()
        self.raise_()

        if not self.exec_():
            return None, None

        action = 'create' if b1.isChecked() else 'restore'
        wallet_type = self.wallet_types[group2.checkedId()][0]
        return action, wallet_type
开发者ID:gjhiggins,项目名称:electrum,代码行数:68,代码来源:installwizard.py

示例12: PlotTypeBox

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class PlotTypeBox(QGroupBox):

    def __init__(self, id):
        QGroupBox.__init__(self)
        self.id = id
        self.setTitle("Adjust plot type")
        self.setToolTip("<p>Adjust plot type (leave "
                            "unchecked to use default)</p>")
        self.setCheckable(True)
        self.setChecked(False)
        self.buttonGroup = QButtonGroup(self)
        self.buttonNames = []
        hbox = HBoxLayout()
        id = 0
        button = QToolButton()
        button.setToolTip("Points")
        self.buttonNames.append("p")
        button.setIcon(QIcon(":custom-chart-point.svg"))
        button.setCheckable(True)
        button.setChecked(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("Lines")
        self.buttonNames.append("l")
        button.setIcon(QIcon(":custom-chart-line.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("Both")
        self.buttonNames.append("b")
        button.setIcon(QIcon(":custom-chart-both.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("Overplotted")
        self.buttonNames.append("o")
        button.setIcon(QIcon(":custom-chart-overplotted.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("Histogram")
        self.buttonNames.append("h")
        button.setIcon(QIcon(":custom-chart-hist.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("Stair steps")
        self.buttonNames.append("s")
        button.setIcon(QIcon(":custom-chart-stairs.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("No plotting")
        self.buttonNames.append("n")
        button.setIcon(QIcon())
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)

        self.setLayout(hbox)

    def parameterValues(self):
        params = QString()
        if self.isChecked():
            params = "'%s'" % str(self.buttonNames[
                self.buttonGroup.checkedId()])
        return {self.id:params}
开发者ID:karstenv,项目名称:manageR,代码行数:81,代码来源:plugins_dialog.py

示例13: BoundingBoxBox

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class BoundingBoxBox(QGroupBox):

    def __init__(self, id):
        QGroupBox.__init__(self)
        self.id = id
        self.setTitle("Adjust bounding box")
        self.setToolTip("<p>Adjust plot bounding box (leave "
                            "unchecked to use default)</p>")
        self.setCheckable(True)
        self.setChecked(False)
        self.buttonGroup = QButtonGroup(self)
        self.buttonNames = []
        hbox = HBoxLayout()
        id = 0
        button = QToolButton()
        button.setToolTip("Outline")
        self.buttonNames.append("o")
        button.setIcon(QIcon(":custom-chart-outline.svg"))
        button.setCheckable(True)
        button.setChecked(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("L shape")
        self.buttonNames.append("l")
        button.setIcon(QIcon(":custom-chart-l-shape.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("7 shape")
        self.buttonNames.append("7")
        button.setIcon(QIcon(":custom-chart-7-shape.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("C shape")
        self.buttonNames.append("c")
        button.setIcon(QIcon(":custom-chart-c-shape.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("U shape")
        self.buttonNames.append("u")
        button.setCheckable(True)
        button.setIcon(QIcon(":custom-chart-u-shape.svg"))
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("] shape")
        self.buttonNames.append("]")
        button.setIcon(QIcon(":custom-chart-]-shape.svg"))
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)
        id += 1
        button = QToolButton()
        button.setToolTip("None")
        self.buttonNames.append("n")
        button.setIcon(QIcon())
        button.setCheckable(True)
        self.buttonGroup.addButton(button, id)
        hbox.addWidget(button)

        self.setLayout(hbox)

    def parameterValues(self):
        params = QString()
        if self.isChecked():
            params.append(", bty='%s'" % str(self.buttonNames[
                self.buttonGroup.checkedId()]))
        return {self.id:params}
开发者ID:karstenv,项目名称:manageR,代码行数:81,代码来源:plugins_dialog.py

示例14: DuplicateDistanceDialog

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]

#.........这里部分代码省略.........
    Dialog class to choose the duplicate distance
    """

    def __init__(self, isComplexPolygon):
        """
        Constructor
        :param isComplexPolygon: for a polygon, if it has interior ring(s)
        """
        QDialog.__init__(self)
        self.setWindowTitle(QCoreApplication.translate("VDLTools", "Duplicate"))
        self.resize(300, 100)
        self.__distanceLabel = QLabel(QCoreApplication.translate("VDLTools", "distance :"))
        self.__distanceLabel.setMinimumHeight(20)
        self.__distanceLabel.setMinimumWidth(50)

        self.__distanceEdit = QLineEdit("inputMask")
        self.__distanceEdit.setMinimumHeight(20)
        self.__distanceEdit.setMinimumWidth(120)
        self.__distanceEdit.setValidator(QDoubleValidator(-1000, 1000, 4, self))

        self.__distanceDirection = QCheckBox(QCoreApplication.translate("VDLTools", "invert direction"))

        self.__previewButton = QPushButton(QCoreApplication.translate("VDLTools", "Preview"))
        self.__previewButton.setMinimumHeight(20)
        self.__previewButton.setMinimumWidth(100)

        self.__okButton = QPushButton(QCoreApplication.translate("VDLTools", "OK"))
        self.__okButton.setMinimumHeight(20)
        self.__okButton.setMinimumWidth(100)

        self.__cancelButton = QPushButton(QCoreApplication.translate("VDLTools", "Cancel"))
        self.__cancelButton.setMinimumHeight(20)
        self.__cancelButton.setMinimumWidth(100)

        self.__layout = QGridLayout()
        self.__layout.addWidget(self.__distanceLabel, 0, 0)
        self.__layout.addWidget(self.__distanceEdit, 0, 1)
        self.__layout.addWidget(self.__distanceDirection, 0, 2)

        if isComplexPolygon:
            self.__polygonLabel = QLabel(
                QCoreApplication.translate("VDLTools", "In which direction the internal part has to be duplicated ?"))
            self.__polygonLabel.setMinimumHeight(20)
            self.__polygonLabel.setMinimumWidth(50)
            self.__layout.addWidget(self.__polygonLabel, 1, 0, 1, 3)

            self.__directions = [QRadioButton(QCoreApplication.translate("VDLTools", "same")),
                                 QRadioButton(QCoreApplication.translate("VDLTools", "opposite"))]
            self.__directions[0].setChecked(True)
            self.__direction_button_group = QButtonGroup()
            for i in range(len(self.__directions)):
                self.__layout.addWidget(self.__directions[i], 2, i+1)
                self.__direction_button_group.addButton(self.__directions[i], i)

        self.__layout.addWidget(self.__previewButton, 3, 0)
        self.__layout.addWidget(self.__okButton, 3, 1)
        self.__layout.addWidget(self.__cancelButton, 3, 2)
        self.setLayout(self.__layout)

    def previewButton(self):
        """
        To get the preview button instance
        :return: preview button instance
        """
        return self.__previewButton

    def okButton(self):
        """
        To get the ok button instance
        :return: ok button instance
        """
        return self.__okButton

    def cancelButton(self):
        """
        To get the cancel button instance
        :return: cancel button instance
        """
        return self.__cancelButton

    def distanceEdit(self):
        """
        To get the distance edit widget
        :return: distance edit widget
        """
        return self.__distanceEdit

    def directionCheck(self):
        """
        To get the direction check button
        :return: direction check button
        """
        return self.__distanceDirection

    def isInverted(self):
        """
        To get if the user want a complex polygon duplication inverted or not
        :return: true if inverted, false otherwise
        """
        return self.__direction_button_group.checkedId() == 1
开发者ID:gusthiot,项目名称:VDLTools,代码行数:104,代码来源:duplicate_distance_dialog.py

示例15: DefaultValueParameterWidget

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import checkedId [as 别名]
class DefaultValueParameterWidget(GenericParameterWidget):

    """Widget class for Default Value Parameter."""

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

        :param parameter: A DefaultValueParameter object.
        :type parameter: DefaultValueParameter

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

        self.radio_button_layout = QHBoxLayout()

        # Create radio button group
        self.input_button_group = QButtonGroup()

        for i in range(len(self._parameter.labels)):
            if '%s' in self._parameter.labels[i]:
                label = (
                    self._parameter.labels[i] %
                    self._parameter.options[i])
            else:
                label = self._parameter.labels[i]

            radio_button = QRadioButton(label)
            self.radio_button_layout.addWidget(radio_button)
            self.input_button_group.addButton(radio_button, i)
            if self._parameter.value == \
                    self._parameter.options[i]:
                radio_button.setChecked(True)

        # Create double spin box for custom value
        self.custom_value = QDoubleSpinBox()
        self.custom_value.setSingleStep(0.1)
        if self._parameter.options[-1]:
            self.custom_value.setValue(self._parameter.options[-1])
        self.radio_button_layout.addWidget(self.custom_value)

        self.toggle_custom_value()

        self.inner_input_layout.addLayout(self.radio_button_layout)

        # Connect
        # noinspection PyUnresolvedReferences
        self.input_button_group.buttonClicked.connect(
            self.toggle_custom_value)

    def raise_invalid_type_exception(self):
        """Raise invalid type."""
        message = 'Expecting element type of %s' % (
            self._parameter.element_type.__name__)
        err = ValueError(message)
        return err

    def get_parameter(self):
        """Obtain list parameter object from the current widget state.

        :returns: A DefaultValueParameter from the current state of widget
        :rtype: DefaultValueParameter
        """
        radio_button_checked_id = self.input_button_group.checkedId()
        # No radio button checked, then default value = None
        if radio_button_checked_id == -1:
            self._parameter.value = None
        # The last radio button (custom) is checked, get the value from the
        # line edit
        elif radio_button_checked_id == len(self._parameter.options) - 1:
            self._parameter.options[radio_button_checked_id] = \
                self.custom_value.value()
            self._parameter.value = self.custom_value.value()
        else:
            self._parameter.value = self._parameter.options[
                radio_button_checked_id]

        return self._parameter

    def set_value(self, value):
        """Set value by item's string.

        :param value: The value.
        :type value: str, int

        :returns: True if success, else False.
        :rtype: bool
        """
        # Find index of choice
        try:
            value_index = self._parameter.options.index(value)
            self.input_button_group.button(value_index).setChecked(True)
        except ValueError:
            last_index = len(self._parameter.options) - 1
            self.input_button_group.button(last_index).setChecked(
                True)
            self.custom_value.setValue(value)

        self.toggle_custom_value()

    def toggle_custom_value(self):
#.........这里部分代码省略.........
开发者ID:akbargumbira,项目名称:inasafe,代码行数:103,代码来源:default_value_parameter_widget.py


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