Python PyQt4.QtGui 模块,QButtonGroup() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用PyQt4.QtGui.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())
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def setupUi(self, Dialog):
        Dialog.resize(316, 238)
        Dialog.setWindowTitle("Select Resolution")
        self.verticalLayout = QtGui.QVBoxLayout(Dialog)
        self.frame = QtGui.QFrame(Dialog)
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.frame)
        self.buttonGroup = QtGui.QButtonGroup(self.frame)
        if len(self.videos)>3: checked_btn = 2 
        else: checked_btn = len(self.videos)-1
        for i, video in enumerate(self.videos):
            radioButton = QtGui.QRadioButton(self.frame)
            radioButton.setText(video.resolution + "   (" + video.extension + ')')
            self.buttonGroup.addButton(radioButton)
            self.verticalLayout_2.addWidget(radioButton)
            if i==checked_btn : radioButton.setChecked(True)
        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout_2.addItem(spacerItem)
        self.verticalLayout.addWidget(self.frame)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)

        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
项目: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)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def createToolBox(self):
        self.buttonGroup = QtGui.QButtonGroup()
        self.buttonGroup.setExclusive(False)
        self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked)

        layout = QtGui.QGridLayout()
        layout.addWidget(self.createCellWidget("Conditional", DiagramItem.Conditional),
                0, 0)
        layout.addWidget(self.createCellWidget("Process", DiagramItem.Step), 0,
                1)
        layout.addWidget(self.createCellWidget("Input/Output", DiagramItem.Io),
                1, 0)

        textButton = QtGui.QToolButton()
        textButton.setCheckable(True)
        self.buttonGroup.addButton(textButton, self.InsertTextButton)
        textButton.setIcon(QtGui.QIcon(QtGui.QPixmap(':/images/textpointer.png')
                            .scaled(30, 30)))
        textButton.setIconSize(QtCore.QSize(50, 50))

        textLayout = QtGui.QGridLayout()
        textLayout.addWidget(textButton, 0, 0, QtCore.Qt.AlignHCenter)
        textLayout.addWidget(QtGui.QLabel("Text"), 1, 0,
                QtCore.Qt.AlignCenter)
        textWidget = QtGui.QWidget()
        textWidget.setLayout(textLayout)
        layout.addWidget(textWidget, 1, 1)

        layout.setRowStretch(3, 10)
        layout.setColumnStretch(2, 10)

        itemWidget = QtGui.QWidget()
        itemWidget.setLayout(layout)

        self.backgroundButtonGroup = QtGui.QButtonGroup()
        self.backgroundButtonGroup.buttonClicked.connect(self.backgroundButtonGroupClicked)

        backgroundLayout = QtGui.QGridLayout()
        backgroundLayout.addWidget(self.createBackgroundCellWidget("Blue Grid",
                ':/images/background1.png'), 0, 0)
        backgroundLayout.addWidget(self.createBackgroundCellWidget("White Grid",
                ':/images/background2.png'), 0, 1)
        backgroundLayout.addWidget(self.createBackgroundCellWidget("Gray Grid",
                ':/images/background3.png'), 1, 0)
        backgroundLayout.addWidget(self.createBackgroundCellWidget("No Grid",
                ':/images/background4.png'), 1, 1)

        backgroundLayout.setRowStretch(2, 10)
        backgroundLayout.setColumnStretch(2, 10)

        backgroundWidget = QtGui.QWidget()
        backgroundWidget.setLayout(backgroundLayout)

        self.toolBox = QtGui.QToolBox()
        self.toolBox.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Ignored))
        self.toolBox.setMinimumWidth(itemWidget.sizeHint().width())
        self.toolBox.addItem(itemWidget, "Basic Flowchart Shapes")
        self.toolBox.addItem(backgroundWidget, "Backgrounds")
项目:quantdigger    作者:andyzsf    | 项目源码 | 文件源码
def createToolBox(self):
        self.buttonGroup = QtGui.QButtonGroup()
        self.buttonGroup.setExclusive(False)
        #self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked)

        layout = QtGui.QGridLayout()
        #layout.addWidget(self.createCellWidget("Conditional", DiagramItem.Conditional), 0, 0)
        #layout.addWidget(self.createCellWidget("Process", DiagramItem.Step), 0, 1)
        #layout.addWidget(self.createCellWidget("Input/Output", DiagramItem.Io), 1, 0)

        textButton = QtGui.QToolButton()
        textButton.setCheckable(True)
        textButton.setIcon(QtGui.QIcon(QtGui.QPixmap(':/images/textpointer.png')
                            .scaled(30, 30)))
        textButton.setIconSize(QtCore.QSize(50, 50))

        textLayout = QtGui.QGridLayout()
        textLayout.addWidget(textButton, 0, 0, QtCore.Qt.AlignHCenter)
        textLayout.addWidget(QtGui.QLabel("Text"), 1, 0,
                QtCore.Qt.AlignCenter)
        textWidget = QtGui.QWidget()
        textWidget.setLayout(textLayout)
        layout.addWidget(textWidget, 1, 1)

        layout.setRowStretch(3, 10)
        layout.setColumnStretch(2, 10)

        itemWidget = QtGui.QWidget()
        itemWidget.setLayout(layout)

        self.backgroundButtonGroup = QtGui.QButtonGroup()
        #self.backgroundButtonGroup.buttonClicked.connect(self.backgroundButtonGroupClicked)

        backgroundLayout = QtGui.QGridLayout()
        backgroundLayout.addWidget(self.createBackgroundCellWidget("Blue Grid",
                ':/images/background1.png'), 0, 0)
        backgroundLayout.addWidget(self.createBackgroundCellWidget("White Grid",
                ':/images/background2.png'), 0, 1)
        backgroundLayout.addWidget(self.createBackgroundCellWidget("Gray Grid",
                ':/images/background3.png'), 1, 0)
        backgroundLayout.addWidget(self.createBackgroundCellWidget("No Grid",
                ':/images/background4.png'), 1, 1)

        backgroundLayout.setRowStretch(2, 10)
        backgroundLayout.setColumnStretch(2, 10)

        backgroundWidget = QtGui.QWidget()
        backgroundWidget.setLayout(backgroundLayout)

        self.toolBox = QtGui.QToolBox()
        self.toolBox.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Ignored))
        self.toolBox.setMinimumWidth(itemWidget.sizeHint().width())
        self.toolBox.addItem(itemWidget, "Basic Flowchart Shapes")
        self.toolBox.addItem(backgroundWidget, "Backgrounds")
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def setStations(self):
        if self.submitType:
            allChk = QtGui.QCheckBox('')
            allChk.setChecked(True)
            self.ESGrid.addWidget(allChk,0,0)
            allChk.installEventFilter(self)
            self.EXPL[allChk] = "Click to select/deselect ALL stations"
            allChk.clicked.connect(self.onSelectAllStations)
        else: stationGroup = QtGui.QButtonGroup(self)

        self.ESGrid.addWidget(QtGui.QLabel('staId'),0,1)
        self.ESGrid.addWidget(QtGui.QLabel('DAS'),0,2)
        self.ESGrid.addWidget(QtGui.QLabel('Latitude'),0,3)
        self.ESGrid.addWidget(QtGui.QLabel('Longitude'),0,4)
        self.ESGrid.addWidget(QtGui.QLabel('Elevation(m)'),0,5)
        self.stationChks = []

        lineSeq = 1
        for sId in self.array['orderedStationIds']:
            s = self.array['stations'][sId]
            if not self.submitType: # receiver gather: user click on a station to open events' form
                s['stationRbtn'] = QtGui.QRadioButton(self.ESPane)
                s['stationRbtn'].installEventFilter(self)
                self.EXPL[s['stationRbtn']] = "Click this station to select/deselect"
                s['stationRbtn'].clicked.connect(self.onSelectStation)
                self.ESGrid.addWidget(s['stationRbtn'], lineSeq, 0)
                stationGroup.addButton(s['stationRbtn'])
            else: # shot gather. This form was opened when user select an event. User can select multi stations befor submitting
                s['stationChk'] = QtGui.QCheckBox('', self.ESPane)
                self.stationChks.append(s['stationChk'])
                s['stationChk'].setChecked(True)
                s['stationChk'].clicked.connect(self.onSelectStationRange)
                s['stationChk'].installEventFilter(self)
                self.EXPL[s['stationChk']] = "Click to select this station"
                self.ESGrid.addWidget(s['stationChk'], lineSeq, 0)

            self.addLabel(self.ESGrid, str(s['stationId']), lineSeq, 1)
            self.addLabel(self.ESGrid, str(s['dasSer']), lineSeq, 2)
            self.addLabel(self.ESGrid, str(s['lat.']), lineSeq, 3)
            self.addLabel(self.ESGrid, str(s['long.']), lineSeq, 4)
            self.addLabel(self.ESGrid, str(s['elev.']), lineSeq, 5)
            lineSeq += 1

        self.selectedStationChks = list(range(len(self.stationChks)))


    ###################################
    # Author: Lan
    # def: addLabel():2015
    # set info labels with background white