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


Python QButtonGroup.setId方法代码示例

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


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

示例1: GSideToolbar

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import setId [as 别名]
class GSideToolbar(QWidget):
    selectionChanged = pyqtSignal(str)

    def __init__(self, buttons):
        super().__init__()

        self.selectedId = None

        self.mainLayout = QVBoxLayout(self)
        self.buttonGroup = QButtonGroup()
        self.buttons = {}

        for button in buttons:
            b = QPushButton(button.name)
            self.buttonGroup.addButton(b)
            self.buttonGroup.setId(b, button.id)
            self.buttons[button.id] = b
            self.mainLayout.addWidget(b)

        self.buttonGroup.buttonClicked.connect(self.buttonClicked)

        self.mainLayout.addStretch()

    def buttonState(self, state):
        pass

    def buttonClicked(self, button : QPushButton):
        buttonId = self.buttonGroup.id(button)
        buttonName = self.buttons[buttonId].text()
        self.selectionChanged.emit(buttonName)

    @staticmethod
    def createButton(text, icon):
        pass
开发者ID:dushko,项目名称:G-,代码行数:36,代码来源:gsidetoolbar.py

示例2: DataCheck

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import setId [as 别名]
class DataCheck(Content):

    def __init__(self, parent=None, button_func=None, params=None):
        super().__init__(parent, 'Data check', params)

        self.button_func = button_func

        path = os.path.abspath(os.path.dirname(__file__)) + '/static/'

        # nr = min(5, data.shape[0])
        nr = len(self.params.data5)

        if params.lang == 'jp':
            text = ('データの読み込み結果(先頭{n}行)を以下に示します.\n'
                    'データを正しく読み込めていることを確認してください.'.format(n=nr))
            self.set_paragraph(
                'データ読み込み結果の確認', text=text)
        else:
            text = ('First {n} rows of your data are shown below.\n'
                    'Confirm that the data was read correctly.'.format(n=nr))
            self.set_paragraph(
                'Check data', text=text)

        table = NonScrollTable(self.inner)

        table.setRowCount(nr)
        table.setColumnCount(len(self.params.columns))
        table.setHorizontalHeaderLabels(self.params.columns)

        for r in range(nr):
            for c in range(len(self.params.columns)):
                item = QTableWidgetItem(str(self.params.data5.iat[r, c]))
                item.setFlags(Qt.ItemIsEnabled)
                table.setItem(r, c, item)

        table.setNonScroll()

        self.vbox.addWidget(table)

        # Text for type checking and objective variable setting
        path1 = path + 'categorical'
        text = self.get_text(path1)
        if self.params.lang == 'en':
            self.set_paragraph(
                'Check type of variables and set objective variable',
                text=text)
        else:
            self.set_paragraph('変数タイプの確認と目的変数の設定', text=text)

        # htable = QTableWidget(self.inner)
        htable = NonScrollTable(self.inner)

        htable.setRowCount(len(self.params.columns))
        htable.setColumnCount(4)
        htable.setHorizontalHeaderLabels(
            ['columns', 'categorical', 'numerical', 'target'])

        self.lst_cat = []
        self.lst_num = []
        self.lst_obj = []
        self.obj_group = QButtonGroup(self.inner)
        for c in range(len(self.params.columns)):
            # col 1
            item = QTableWidgetItem(self.params.columns[c])
            item.setFlags(Qt.ItemIsEnabled)
            htable.setItem(c, 0, item)

            group = QButtonGroup(self.inner)

            # col 2
            htable.setCellWidget(
                c, 1,
                self.__make_cell(c, 'cat', self.params.col_types[c],
                                 self.params.col_types_def[c]))
            group.addButton(self.lst_cat[-1])

            # col 3
            htable.setCellWidget(
                c, 2,
                self.__make_cell(c, 'num', self.params.col_types[c],
                                 self.params.col_types_def[c]))
            group.addButton(self.lst_num[-1])

            # col 4
            htable.setCellWidget(
                c, 3,
                self.__make_cell(c, 'obj', self.params.col_types[c],
                                 self.params.col_types_def[c]))
            self.obj_group.addButton(self.lst_obj[-1])
            self.obj_group.setId(self.lst_obj[-1], c)

        htable.setNonScroll()

        self.vbox.addWidget(htable)

        if self.params.lang == 'jp':
            self.txt_cnf = ('<font color="red">目的変数を1つ選択し,'
                    'targetの列にチェックをいれてください。')
            if self.params.task.lower() == 'classification':
                self.txt_cnf += '<br>目的変数はカテゴリ変数である必要があります。</font>'
#.........这里部分代码省略.........
开发者ID:canard0328,项目名称:malss,代码行数:103,代码来源:data_check.py

示例3: request_trezor_init_settings

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import setId [as 别名]
    def request_trezor_init_settings(self, wizard, method, device):
        vbox = QVBoxLayout()
        next_enabled = True
        label = QLabel(_("Enter a label to name your device:"))
        name = QLineEdit()
        hl = QHBoxLayout()
        hl.addWidget(label)
        hl.addWidget(name)
        hl.addStretch(1)
        vbox.addLayout(hl)

        def clean_text(widget):
            text = widget.toPlainText().strip()
            return ' '.join(text.split())

        if method in [TIM_NEW, TIM_RECOVER]:
            gb = QGroupBox()
            hbox1 = QHBoxLayout()
            gb.setLayout(hbox1)
            # KeepKey recovery doesn't need a word count
            if method == TIM_NEW:
                vbox.addWidget(gb)
            gb.setTitle(_("Select your seed length:"))
            bg = QButtonGroup()
            for i, count in enumerate([12, 18, 24]):
                rb = QRadioButton(gb)
                rb.setText(_("{} words").format(count))
                bg.addButton(rb)
                bg.setId(rb, i)
                hbox1.addWidget(rb)
                rb.setChecked(True)
            cb_pin = QCheckBox(_('Enable PIN protection'))
            cb_pin.setChecked(True)
        else:
            text = QTextEdit()
            text.setMaximumHeight(60)
            if method == TIM_MNEMONIC:
                msg = _("Enter your BIP39 mnemonic:")
            else:
                msg = _("Enter the master private key beginning with xprv:")
                def set_enabled():
                    from electrum.bip32 import is_xprv
                    wizard.next_button.setEnabled(is_xprv(clean_text(text)))
                text.textChanged.connect(set_enabled)
                next_enabled = False

            vbox.addWidget(QLabel(msg))
            vbox.addWidget(text)
            pin = QLineEdit()
            pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}')))
            pin.setMaximumWidth(100)
            hbox_pin = QHBoxLayout()
            hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):")))
            hbox_pin.addWidget(pin)
            hbox_pin.addStretch(1)

        if method in [TIM_NEW, TIM_RECOVER]:
            vbox.addWidget(WWLabel(RECOMMEND_PIN))
            vbox.addWidget(cb_pin)
        else:
            vbox.addLayout(hbox_pin)

        passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        cb_phrase = QCheckBox(_('Enable passphrases'))
        cb_phrase.setChecked(False)
        vbox.addWidget(passphrase_msg)
        vbox.addWidget(passphrase_warning)
        vbox.addWidget(cb_phrase)

        wizard.exec_layout(vbox, next_enabled=next_enabled)

        if method in [TIM_NEW, TIM_RECOVER]:
            item = bg.checkedId()
            pin = cb_pin.isChecked()
        else:
            item = ' '.join(str(clean_text(text)).split())
            pin = str(pin.text())

        return (item, name.text(), pin, cb_phrase.isChecked())
开发者ID:vialectrum,项目名称:vialectrum,代码行数:83,代码来源:qt.py

示例4: exampleQMainWindow

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import setId [as 别名]
class exampleQMainWindow (QWidget):

    def __init__(self):
        super(exampleQMainWindow, self).__init__()
        # Create QListWidget
        self.myQListWidget = QListWidget(self)
        self.myQListWidget.setStyleSheet("""
            QListWidget:item:selected:active {
            background-color:#A6A4FF;}
            """)

        self.setMinimumSize(350, 500)
        self.config = configparser.ConfigParser()
        self.config.read('prefs.cfg')

        self.extention = QLineEdit()
        self.filename = QLineEdit()
        self.add_type = QPushButton("add type")
        self.del_type = QPushButton("del type")
        self.color_button = color_picker(parent=self)
        self.pattern_icon = Pattern_button(parent=self)
        self.radio_button_one = QRadioButton('Classic')
        self.radio_button_two = QRadioButton('Magellan')
        self.radio_group = QGroupBox('operation mode')
        self.radio_group.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.pattern_group = QGroupBox('window pattern and text color')
        self.pattern_group.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        self.button_group = QButtonGroup()
        self.button_group.addButton(self.radio_button_one)
        self.button_group.addButton(self.radio_button_two)
        self.button_group.setId(self.radio_button_one, 1)
        self.button_group.setId(self.radio_button_two, 2)

        self.mainlayout = QVBoxLayout()
        self.holdgroups_layout = QHBoxLayout()
        self.radio_button_layout = QVBoxLayout()
        self.pattern_label_layout = QHBoxLayout()
        self.add_filetype_layout = QFormLayout()
        self.add_del_button_layout = QHBoxLayout()

        # adding
        self.holdgroups_layout.addWidget(self.radio_group)
        self.holdgroups_layout.addWidget(self.pattern_group)

        self.pattern_label_layout.addWidget(self.pattern_icon)
        self.pattern_label_layout.addStretch(1)
        self.pattern_label_layout.addWidget(self.color_button)
        self.pattern_label_layout.addStretch(1)
        self.pattern_group.setLayout(self.pattern_label_layout)

        self.radio_button_layout.addWidget(self.radio_button_one)
        self.radio_button_layout.addWidget(self.radio_button_two)
        self.radio_group.setLayout(self.radio_button_layout)

        self.add_filetype_layout.addRow('extention', self.extention)
        self.add_filetype_layout.addRow('path to icon', self.filename)
        self.add_del_button_layout.addWidget(self.add_type)
        self.add_del_button_layout.addWidget(self.del_type)

        # layouts settings 
        # self.radio_button_layout.setGeometry(QRect(10, 10, 10, 10))
        self.add_filetype_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        # self.pattern_icon.setPixmap(QPixmap("./images/pattern.png").scaledToWidth(80)) 
        self.mainlayout.setContentsMargins(5, 5, 5, 0)
        self.mainlayout.setSpacing(7)   

        # reading stored settings
        for key, value in self.config.items('icons'):
            myQCustomQWidget = QCustomQWidget()
            myQCustomQWidget.setTextUp("filetype: " + key.upper())
            myQCustomQWidget.setTextDown(value)
            myQCustomQWidget.setIcon(os.path.dirname(os.path.realpath(__file__)) + value)
            myQListWidgetItem = QListWidgetItem(self.myQListWidget) 
            myQListWidgetItem.setSizeHint(myQCustomQWidget.sizeHint()) 
            self.myQListWidget.addItem(myQListWidgetItem)
            self.myQListWidget.setItemWidget(myQListWidgetItem, myQCustomQWidget) 

        # adding elements to layout
        self.mainlayout.addLayout(self.holdgroups_layout)
        self.mainlayout.insertSpacing(10, 10)
        self.mainlayout.addWidget(self.myQListWidget)
        self.mainlayout.addLayout(self.add_filetype_layout)    
        self.mainlayout.addLayout(self.add_del_button_layout)
        self.setLayout(self.mainlayout) 
开发者ID:freeaks,项目名称:filer,代码行数:87,代码来源:prefs.py

示例5: request_trezor_init_settings

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import setId [as 别名]
    def request_trezor_init_settings(self, wizard, method, device_id):
        vbox = QVBoxLayout()
        next_enabled = True

        devmgr = self.device_manager()
        client = devmgr.client_by_id(device_id)
        if not client:
            raise Exception(_("The device was disconnected."))
        model = client.get_trezor_model()
        fw_version = client.client.version

        # label
        label = QLabel(_("Enter a label to name your device:"))
        name = QLineEdit()
        hl = QHBoxLayout()
        hl.addWidget(label)
        hl.addWidget(name)
        hl.addStretch(1)
        vbox.addLayout(hl)

        # word count
        gb = QGroupBox()
        hbox1 = QHBoxLayout()
        gb.setLayout(hbox1)
        vbox.addWidget(gb)
        gb.setTitle(_("Select your seed length:"))
        bg_numwords = QButtonGroup()
        word_counts = (12, 18, 24)
        for i, count in enumerate(word_counts):
            rb = QRadioButton(gb)
            rb.setText(_("{:d} words").format(count))
            bg_numwords.addButton(rb)
            bg_numwords.setId(rb, i)
            hbox1.addWidget(rb)
            rb.setChecked(True)

        # PIN
        cb_pin = QCheckBox(_('Enable PIN protection'))
        cb_pin.setChecked(True)
        vbox.addWidget(WWLabel(RECOMMEND_PIN))
        vbox.addWidget(cb_pin)

        # "expert settings" button
        expert_vbox = QVBoxLayout()
        expert_widget = QWidget()
        expert_widget.setLayout(expert_vbox)
        expert_widget.setVisible(False)
        expert_button = QPushButton(_("Show expert settings"))
        def show_expert_settings():
            expert_button.setVisible(False)
            expert_widget.setVisible(True)
        expert_button.clicked.connect(show_expert_settings)
        vbox.addWidget(expert_button)

        # passphrase
        passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        cb_phrase = QCheckBox(_('Enable passphrases'))
        cb_phrase.setChecked(False)
        expert_vbox.addWidget(passphrase_msg)
        expert_vbox.addWidget(passphrase_warning)
        expert_vbox.addWidget(cb_phrase)

        # ask for recovery type (random word order OR matrix)
        bg_rectype = None
        if method == TIM_RECOVER and not model == 'T':
            gb_rectype = QGroupBox()
            hbox_rectype = QHBoxLayout()
            gb_rectype.setLayout(hbox_rectype)
            expert_vbox.addWidget(gb_rectype)
            gb_rectype.setTitle(_("Select recovery type:"))
            bg_rectype = QButtonGroup()

            rb1 = QRadioButton(gb_rectype)
            rb1.setText(_('Scrambled words'))
            bg_rectype.addButton(rb1)
            bg_rectype.setId(rb1, RECOVERY_TYPE_SCRAMBLED_WORDS)
            hbox_rectype.addWidget(rb1)
            rb1.setChecked(True)

            rb2 = QRadioButton(gb_rectype)
            rb2.setText(_('Matrix'))
            bg_rectype.addButton(rb2)
            bg_rectype.setId(rb2, RECOVERY_TYPE_MATRIX)
            hbox_rectype.addWidget(rb2)

        # no backup
        cb_no_backup = None
        if method == TIM_NEW:
            cb_no_backup = QCheckBox(f'''{_('Enable seedless mode')}''')
            cb_no_backup.setChecked(False)
            if (model == '1' and fw_version >= (1, 7, 1)
                    or model == 'T' and fw_version >= (2, 0, 9)):
                cb_no_backup.setToolTip(SEEDLESS_MODE_WARNING)
            else:
                cb_no_backup.setEnabled(False)
                cb_no_backup.setToolTip(_('Firmware version too old.'))
            expert_vbox.addWidget(cb_no_backup)

#.........这里部分代码省略.........
开发者ID:faircoin,项目名称:electrumfair,代码行数:103,代码来源:qt.py


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