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


Python QButtonGroup.setId方法代码示例

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


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

示例1: RadioBooleanFilter

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import setId [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: choice

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import setId [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

示例3: CategoryButtons

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import setId [as 别名]
class CategoryButtons(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        Layout = QHBoxLayout(self)
        self.group = QButtonGroup(self)
        for i, (k, color) in enumerate(ORDERED):
            button = QPushButton(k)
            palette = QPalette(button.palette())
            palette.setColor(QPalette.Button, color)
            button.setPalette(palette)
            self.group.addButton(button)
            self.group.setId(button, i)
            Layout.addWidget(button)
        QObject.connect(self.group,
                        SIGNAL('buttonClicked(QAbstractButton *)'),
                        self.clicked)

    def clicked(self, button):
        category = ORDERED[self.group.id(button)][0]
        self.emit(SIGNAL('selected(QString &)'), category)
开发者ID:RikVerschueren,项目名称:AccordionMega,代码行数:22,代码来源:categories.py

示例4: restore_or_create

# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import setId [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


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