Python PyQt5.QtWidgets 模块,QButtonGroup() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PyQt5.QtWidgets.QButtonGroup()

项目:Dragonfly    作者:duaneloh    | 项目源码 | 文件源码
def add_classes_frame(self):
        self.vbox.setStretch(self.vbox.count()-1, 0)

        hbox = QtWidgets.QHBoxLayout()
        self.vbox.addLayout(hbox)
        self.class_line = QtWidgets.QGridLayout()
        hbox.addLayout(self.class_line)
        hbox.addStretch(1)
        self.class_num = QtWidgets.QButtonGroup()
        self.refresh_classes()

        hbox = QtWidgets.QHBoxLayout()
        self.vbox.addLayout(hbox)
        button = QtWidgets.QPushButton('Show', self)
        button.clicked.connect(self.show_selected_class)
        hbox.addWidget(button)
        button = QtWidgets.QPushButton('See all', self)
        button.clicked.connect(self.show_all_classes)
        hbox.addWidget(button)
        button = QtWidgets.QPushButton('Refresh', self)
        button.clicked.connect(self.refresh_classes)
        hbox.addWidget(button)
        hbox.addStretch(1)

        self.vbox.addStretch(1)
项目:Dragonfly    作者:duaneloh    | 项目源码 | 文件源码
def refresh_class_line(self):
        for i in reversed(range(self.class_line.count())):
            w = self.class_line.itemAt(i).widget()
            self.class_line.removeWidget(w)
            w.setParent(None)
        self.class_num = QtWidgets.QButtonGroup()
        button = QtWidgets.QRadioButton('All')
        button.setChecked(True)
        self.class_num.addButton(button, 0)
        self.class_line.addWidget(button, 0, 0)
        for i, k in enumerate(self.classes.key):
            if k == ' ':
                text = '  '
            else:
                text = k
            button = QtWidgets.QRadioButton(text, self)
            self.class_num.addButton(button, i+1)
            self.class_line.addWidget(button, (i+1)/5, (i+1)%5)
        self.class_list_summary.setText(self.classes.gen_summary())
项目:Cfd    作者:qingfengxia    | 项目源码 | 文件源码
def __init__(self, choices, title = "select one from choices", parent = None):
        super(ChoiceDialog, self).__init__(parent)

        layout = QVBoxLayout(self)
        self.choiceButtonGroup=QButtonGroup(parent)  # it is not a visible UI
        self.choiceButtonGroup.setExclusive(True)
        if choices and len(choices)>=1:
            self.choices = choices
            for id, choice in enumerate(self.choices):
                rb = QRadioButton(choice)
                self.choiceButtonGroup.addButton(rb)
                self.choiceButtonGroup.setId(rb, id)  # negative id if not specified
                layout.addWidget(rb)

        self.choiceButtonGroup.buttonClicked.connect(self.choiceChanged)
        # OK and Cancel buttons
        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)

        self.setLayout(layout)
        self.setWindowTitle(title)
项目:thegame    作者:afg984    | 项目源码 | 文件源码
def initAbilityButtons(self):
        self.abilityButtons = []
        self.abilityButtonGroup = QButtonGroup(self)
        for ab in Ability:
            text = ab.as_camel.replace('_', ' ')
            label = QLabel(text, self)
            button = QPushButton('+', self)
            self.abilityButtons.append((label, button))
            label.setVisible(True)
            label.setEnabled(False)
            button.setVisible(True)
            button.setEnabled(False)
            self.abilityButtonGroup.addButton(button, ab)
        self.setAbilityButtonStyle()
项目:mindfulness-at-the-computer    作者:SunyataZero    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        self.show()
        self.raise_()
        self.showNormal()

        self.updating_gui_bool = False
        # self.rest_actions_qbg = QtWidgets.QButtonGroup()
        vbox_l2 = QtWidgets.QVBoxLayout()
        self.setLayout(vbox_l2)

        hbox_l3 = QtWidgets.QHBoxLayout()
        vbox_l2.addStretch(1)
        vbox_l2.addLayout(hbox_l3)
        vbox_l2.addStretch(1)

        # Main area
        self.main_area_qgb = QtWidgets.QGroupBox("Rest Actions")
        hbox_l3.addWidget(self.main_area_qgb)

        self.actions_list_vbox_l4 = QtWidgets.QVBoxLayout()
        self.main_area_qgb.setLayout(self.actions_list_vbox_l4)

        walking_mindfully_qll = QtWidgets.QLabel("Please move and walk mindfully when leaving the computer")
        walking_mindfully_qll.setFont(mc_global.get_font_medium())
        vbox_l2.addWidget(walking_mindfully_qll)
        vbox_l2.addStretch(1)

        buttons_hbox_l3 = QtWidgets.QHBoxLayout()
        vbox_l2.addLayout(buttons_hbox_l3)

        self.close_qpb = QtWidgets.QPushButton("Close")
        buttons_hbox_l3.addWidget(self.close_qpb)
        self.close_qpb.clicked.connect(self.on_close_clicked)

        self.close_and_breathe_qpb = QtWidgets.QPushButton("Close and Breathe")
        buttons_hbox_l3.addWidget(self.close_and_breathe_qpb)
        self.close_and_breathe_qpb.clicked.connect(self.on_close_and_breathe_clicked)

        self.setup_rest_action_list()
项目:pyqt-sqlite    作者:mbaser    | 项目源码 | 文件源码
def __init__(self, parent=None, *args):
        super(ModifyTableDialog, self).__init__(*args)
        self.parent=parent
        self.setupUi(self)
        self.model=self.tableWidget.model()
        self.buttonBox.buttons()[0].setEnabled(False)
        self.commandLinkButton_2.setEnabled(False)
        self.rc_count=0
        self.ai_button_group=QtWidgets.QButtonGroup()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, wizard_state ):
        super().__init__()

        self.wizard_state = wizard_state

        self.setTitle( T_('Add Project') )
        self.setSubTitle( T_('Where is the Project?') )

        self.radio_browse_existing = QtWidgets.QRadioButton( T_('Browse for an existing project') )
        self.radio_scan_for_existing = QtWidgets.QRadioButton( T_('Scan for existing projects') )

        self.radio_scan_for_existing.setChecked( True )
        self.radio_browse_existing.setChecked( False )

        self.grp_show = QtWidgets.QButtonGroup()
        self.grp_show.addButton( self.radio_scan_for_existing )
        self.grp_show.addButton( self.radio_browse_existing )

        self.all_clone_radio = []
        for id_, page in sorted( wizard_state.all_clone_pages.items() ):
            radio = QtWidgets.QRadioButton( page.radioButtonLabel() )
            self.all_clone_radio.append( (id_, radio) )
            self.grp_show.addButton( radio )

        self.all_init_radio = []
        for id_, page in sorted( wizard_state.all_init_pages.items() ):
            radio = QtWidgets.QRadioButton( page.radioButtonLabel() )
            self.all_init_radio.append( (id_, radio) )
            self.grp_show.addButton( radio )

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget( QtWidgets.QLabel( '<b>%s</b>' % (T_('Add an existing local project'),) ) )
        layout.addWidget( self.radio_scan_for_existing )
        layout.addWidget( self.radio_browse_existing )

        layout.addWidget( QtWidgets.QLabel( '<b>%s</b>' % (T_('Add an external project'),) ) )
        for id_, radio in self.all_clone_radio:
            layout.addWidget( radio )

        layout.addWidget( QtWidgets.QLabel( '<b>%s</b>' % (T_('Create an empty project'),) ) )
        for id_, radio in self.all_init_radio:
            layout.addWidget( radio )

        self.setLayout( layout )
项目:Dragonfly    作者:duaneloh    | 项目源码 | 文件源码
def add_roi_frame(self):
        self.vbox.setStretch(self.vbox.count()-1, 0)
        self.roi_frame = QtWidgets.QFrame(self)
        self.vbox.addWidget(self.roi_frame)
        self.vbox.addStretch(1)
        vbox = QtWidgets.QVBoxLayout()
        self.roi_frame.setLayout(vbox)

        self.roi_summary = QtWidgets.QLabel('', self)
        vbox.addWidget(self.roi_summary)

        hbox = QtWidgets.QHBoxLayout()
        vbox.addLayout(hbox)
        button = QtWidgets.QPushButton('Clear ROIs', self)
        button.clicked.connect(self.clear_roi)
        hbox.addWidget(button)
        hbox.addStretch(1)

        hbox = QtWidgets.QHBoxLayout()
        vbox.addLayout(hbox)
        self.roi_choice = QtWidgets.QGridLayout()
        self.current_roi = QtWidgets.QButtonGroup()
        hbox.addLayout(self.roi_choice)
        hbox.addStretch(1)

        hbox = QtWidgets.QHBoxLayout()
        vbox.addLayout(hbox)
        button = QtWidgets.QPushButton('Prev', self)
        button.clicked.connect(self.prev_frame)
        hbox.addWidget(button)
        button = QtWidgets.QPushButton('Next', self)
        button.clicked.connect(self.next_frame)
        hbox.addWidget(button)
        button = QtWidgets.QPushButton('Random', self)
        button.clicked.connect(self.rand_frame)
        hbox.addWidget(button)
        hbox.addStretch(1)

        hbox = QtWidgets.QHBoxLayout()
        vbox.addLayout(hbox)
        self.class_tag = QtWidgets.QLineEdit('', self)
        self.class_tag.setFixedWidth(24)
        hbox.addWidget(self.class_tag)
        button = QtWidgets.QPushButton('Apply Class', self)
        button.clicked.connect(self.apply_class)
        hbox.addWidget(button)
        hbox.addStretch(1)

        hbox = QtWidgets.QHBoxLayout()
        vbox.addLayout(hbox)
        self.class_fname = QtWidgets.QLineEdit(self.classes.fname, self)
        self.class_fname.editingFinished.connect(self.update_name)
        hbox.addWidget(self.class_fname)
        button = QtWidgets.QPushButton('Save Classes', self)
        button.clicked.connect(self.classes.save)
        hbox.addWidget(button)
        hbox.addStretch(1)