本文整理汇总了Python中PyQt5.QtWidgets.QButtonGroup类的典型用法代码示例。如果您正苦于以下问题:Python QButtonGroup类的具体用法?Python QButtonGroup怎么用?Python QButtonGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QButtonGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createToolBox
def createToolBox(self):
self.buttonGroup = QButtonGroup()
self.buttonGroup.setExclusive(False)
self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked)
layout = QGridLayout()
layout.addWidget(self.createCellWidget("Diamond", ITGItem.Diamond),
0, 0)
layout.addWidget(self.createCellWidget("Square", ITGItem.Square), 0,
1)
layout.addWidget(self.createCellWidget("Parallelogram", ITGItem.Parallelogram),
1, 0)
layout.setRowStretch(3, 10)
layout.setColumnStretch(2, 10)
itemWidget = QWidget()
itemWidget.setLayout(layout)
self.backgroundButtonGroup = QButtonGroup()
self.toolBox = QToolBox()
self.toolBox.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored))
self.toolBox.setMinimumWidth(itemWidget.sizeHint().width())
self.toolBox.addItem(itemWidget, "Basic Components")
示例2: Ui_Widget
class Ui_Widget(object):
""" Klasa definiująca GUI """
def setupUi(self, Widget):
# widgety rysujące kształty, instancje klasy Ksztalt
self.ksztalt1 = Ksztalt(self, Ksztalty.Polygon)
self.ksztalt2 = Ksztalt(self, Ksztalty.Ellipse)
self.ksztaltAktywny = self.ksztalt1
# przyciski CheckBox ###
uklad = QVBoxLayout() # układ pionowy
self.grupaChk = QButtonGroup()
for i, v in enumerate(('Kwadrat', 'Koło', 'Trójkąt', 'Linia')):
self.chk = QCheckBox(v)
self.grupaChk.addButton(self.chk, i)
uklad.addWidget(self.chk)
self.grupaChk.buttons()[self.ksztaltAktywny.ksztalt].setChecked(True)
# CheckBox do wyboru aktywnego kształtu
self.ksztaltChk = QCheckBox('<=')
self.ksztaltChk.setChecked(True)
uklad.addWidget(self.ksztaltChk)
# układ poziomy dla kształtów oraz przycisków CheckBox
ukladH1 = QHBoxLayout()
ukladH1.addWidget(self.ksztalt1)
ukladH1.addLayout(uklad)
ukladH1.addWidget(self.ksztalt2)
# koniec CheckBox ###
self.setLayout(ukladH1) # przypisanie układu do okna głównego
self.setWindowTitle('Widżety')
示例3: intervalButtons
def intervalButtons(self):
widget = QGroupBox('Interval')
group = QButtonGroup(widget)
layout = QHBoxLayout()
widget.setLayout(layout)
def setInterval():
self.interval = group.checkedId()
interval = self.INTERVALS[self.interval][0]
self.updateTitle()
if interval:
self.progress.show()
self.progress.setMaximum(interval)
value = self.timer.seconds()
if value < interval:
self.progress.resume()
else:
self.progress.stop()
self.progress.setValue(min(interval, value))
else:
self.progress.hide()
for i, interval in enumerate(self.INTERVALS):
button = QPushButton(interval[1])
button.setCheckable(True)
button.clicked.connect(setInterval)
group.addButton(button, i)
layout.addWidget(button, 1 if i > 0 else 0)
return widget
示例4: add_radiobuttons
def add_radiobuttons(self, tab=False):
from PyQt5.QtWidgets import QRadioButton, QButtonGroup, QVBoxLayout
scrollLayout = QVBoxLayout()
buttonGroup = QButtonGroup()
buttongroup_results = {}
i = 1
if tab:
name = "tab"
i = 2
elif arguments.radiolist:
name = "radiolist"
elif arguments.menu:
name = "menu"
arglen = len(arguments.__dict__[name])
while i < arglen:
if arguments.radiolist:
radiobutton = QRadioButton(arguments.__dict__[name][i+1])
buttongroup_results[radiobutton] = arguments.__dict__[name][i]
if arguments.__dict__[name][i+2].lower() in ["true", "on"]:
radiobutton.setChecked(True)
i += 3
else:
radiobutton = QRadioButton(arguments.__dict__[name][i+1])
buttongroup_results[radiobutton] = arguments.__dict__[name][i]
if i == 1:
radiobutton.setChecked(True)
i += 2
scrollLayout.addWidget(radiobutton)
buttonGroup.addButton(radiobutton)
return scrollLayout, buttonGroup, buttongroup_results
示例5: __init__
def __init__(self, player, engine, colour=None, parent=None):
super(PochaPlayerInputWidget, self).__init__(parent)
self.player = player
self.engine = engine
self.winner = False
self.pcolour = colour
self.mainLayout = QVBoxLayout(self)
self.mainLayout.setSpacing(0)
self.label = QLabel(self)
self.label.setText(self.player)
self.mainLayout.addWidget(self.label)
self.label.setAutoFillBackground(False)
self.setFrameShape(QFrame.Panel)
self.setFrameShadow(QFrame.Raised)
self.label.setScaledContents(True)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setWordWrap(False)
css = ("QLabel {{ font-size: 24px; font-weight: bold; "
"color:rgb({},{},{});}}")
self.label.setStyleSheet(css.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
self.expectedGroupBox = QFrame(self)
self.mainLayout.addWidget(self.expectedGroupBox)
self.ebLayout = QHBoxLayout(self.expectedGroupBox)
self.ebLayout.setSpacing(0)
self.ebLayout.setContentsMargins(2, 2, 2, 2)
self.expectedGroup = QButtonGroup(self)
self.expectedGroup.buttonReleased.connect(self.expectedClickedAction)
self.expectedButtons = []
self.wonGroupBox = QFrame(self)
self.mainLayout.addWidget(self.wonGroupBox)
self.wbLayout = QHBoxLayout(self.wonGroupBox)
self.wbLayout.setSpacing(0)
self.wbLayout.setContentsMargins(2, 2, 2, 2)
self.wonGroup = QButtonGroup(self)
self.wonGroup.buttonReleased.connect(self.wonClickedAction)
self.wonButtons = []
for i in range(-1, 9):
button = PochaHandsButton(str(i), self)
self.expectedGroup.addButton(button, i)
self.expectedButtons.append(button)
button.toggled.connect(self.enableWonGroup)
if i < 0:
button.hide()
else:
self.ebLayout.addWidget(button)
button = PochaHandsButton(str(i), self)
self.wonGroup.addButton(button, i)
self.wonButtons.append(button)
if i < 0:
button.hide()
else:
self.wbLayout.addWidget(button)
self.reset()
示例6: LabelButtonGroup
class LabelButtonGroup(QWidget):
def __init__(self, label = '', buttons = {'UJ object reference value': 'Name to show'}):
super(LabelButtonGroup, self).__init__()
self.label = QLabel()
self.label.setText(label)
self.button_group = QButtonGroup()
self.buttons = {}
self.layout = QHBoxLayout()
self.layout.setContentsMargins(0,0,0,0)
self.layout.addWidget(self.label)
for button_key in buttons.keys():
self.buttons[button_key] = QRadioButton(buttons[button_key])
self.button_group.addButton(self.buttons[button_key])
self.layout.addWidget(self.buttons[button_key])
def show(self):
for button in self.buttons.values():
button.show()
self.label.show()
def hide(self):
for button in self.buttons.values():
button.hide()
self.label.hide()
def set_text(self, key):
if key != '':
self.buttons[key].setChecked(1)
def text(self):
return self.button_group.checkedButton().text()
def checked(self):
return self.button_group.checkedButton()
示例7: GSideToolbar
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
示例8: initUI
def initUI(self):
self.widgetLayout = QHBoxLayout(self)
self.playerGroup = QGroupBox(self)
self.widgetLayout.addWidget(self.playerGroup)
self.playerButtonGroup = QButtonGroup(self)
self.playerGroupLayout = QGridLayout(self.playerGroup)
b = QRadioButton("", self.playerGroup)
# self.playerGroupLayout.addWidget(b)
self.playerButtonGroup.addButton(b, 0)
self.playerButtons = [b]
b.hide()
for i, player in enumerate(self.engine.getListPlayers(), 1):
b = QRadioButton(
'{}. {}'.format(i, player), self.playerGroup)
if len(self.engine.getListPlayers()) > 2:
self.playerGroupLayout.addWidget(b, (i-1) % 2, (i-1)/2)
else:
self.playerGroupLayout.addWidget(b, 0, (i-1) % 2)
self.playerButtonGroup.addButton(b, i)
self.playerButtons.append(b)
self.kindGroup = QGroupBox(self)
self.widgetLayout.addWidget(self.kindGroup)
self.kindButtonGroup = QButtonGroup(self)
self.kindGroupLayout = QGridLayout(self.kindGroup)
b = QRadioButton("", self.kindGroup)
# self.kindGroupLayout.addWidget(b)
self.kindButtonGroup.addButton(b, 0)
self.kindButtons = [b]
b.hide()
self.scoreSpinBox = ScoreSpinBox(self)
self.scoreSpinBox.setAlignment(QtCore.Qt.AlignCenter)
self.scoreSpinBox.setMaximumWidth(60)
self.scoreSpinBox.setRange(0, 300)
for i, kind in enumerate(self.engine.getEntryKinds(), 1):
lbl = i18n("CarcassonneInputWidget", kind)
b = QRadioButton('{}. {}'.format(i, lbl), self.kindGroup)
self.kindGroupLayout.addWidget(b, (i-1) % 2, (i-1)/2)
self.kindButtonGroup.addButton(b, i)
b.clicked.connect(self.scoreSpinBox.setFocus)
self.kindButtons.append(b)
self.kindButtons[3].toggled.connect(self.setCloisterPoints)
self.kindButtons[5].toggled.connect(self.setGoodsPoints)
self.kindButtons[6].toggled.connect(self.setFairPoints)
self.scoreGroup = QGroupBox(self)
self.widgetLayout.addWidget(self.scoreGroup)
self.scoreGroupLayout = QHBoxLayout(self.scoreGroup)
self.scoreGroupLayout.addWidget(self.scoreSpinBox)
self.reset()
self.retranslateUI()
示例9: DyStockSelectAddColumnsDlg
class DyStockSelectAddColumnsDlg(QDialog):
def __init__(self, data, title, parent=None):
super().__init__(parent)
self._data = data
self._initUi(title)
def _initUi(self, title):
self.setWindowTitle('添加{0}列'.format(title))
# 控件
increaseColumnsLable = QLabel('基准日期几日{0}'.format(title))
self._increaseColumnsLineEdit = QLineEdit(','.join(self._data['days']) if self._data else '2,3,4,5,10' )
# 前 & 后
forwardRadioButton = QRadioButton('向前')
backwardRadioButton = QRadioButton('向后'); backwardRadioButton.setChecked(True)
# 添加到QButtonGroup
self._wardButtonGroup = QButtonGroup()
self._wardButtonGroup.addButton(forwardRadioButton, 1);
self._wardButtonGroup.addButton(backwardRadioButton, 2)
cancelPushButton = QPushButton('Cancel')
okPushButton = QPushButton('OK')
cancelPushButton.clicked.connect(self._cancel)
okPushButton.clicked.connect(self._ok)
# 布局
grid = QGridLayout()
grid.setSpacing(10)
grid.addWidget(increaseColumnsLable, 0, 0, 1, 2)
grid.addWidget(self._increaseColumnsLineEdit, 1, 0, 1, 2)
grid.addWidget(forwardRadioButton, 2, 0)
grid.addWidget(backwardRadioButton, 2, 1)
grid.addWidget(okPushButton, 3, 1)
grid.addWidget(cancelPushButton, 3, 0)
self.setLayout(grid)
self.setMinimumWidth(QApplication.desktop().size().width()//5)
def _ok(self):
checkedButton = self._wardButtonGroup.checkedButton()
text = checkedButton.text()
self._data['backward'] = True if text == '向后' else False
self._data['days'] = [int(x) for x in self._increaseColumnsLineEdit.text().split(',')]
self.accept()
def _cancel(self):
self.reject()
示例10: createToolBox
def createToolBox(self):
self.buttonGroup = QButtonGroup()
self.buttonGroup.setExclusive(False)
self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked)
layout = 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 = QToolButton()
textButton.setCheckable(True)
self.buttonGroup.addButton(textButton, self.InsertTextButton)
textButton.setIcon(QIcon(QPixmap(':/images/textpointer.png').scaled(30, 30)))
textButton.setIconSize(QSize(50, 50))
textLayout = QGridLayout()
textLayout.addWidget(textButton, 0, 0, Qt.AlignHCenter)
textLayout.addWidget(QLabel("Text"), 1, 0, Qt.AlignCenter)
textWidget = QWidget()
textWidget.setLayout(textLayout)
layout.addWidget(textWidget, 1, 1)
layout.setRowStretch(3, 10)
layout.setColumnStretch(2, 10)
itemWidget = QWidget()
itemWidget.setLayout(layout)
self.backgroundButtonGroup = QButtonGroup()
self.backgroundButtonGroup.buttonClicked.connect(self.backgroundButtonGroupClicked)
backgroundLayout = 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 = QWidget()
backgroundWidget.setLayout(backgroundLayout)
self.toolBox = QToolBox()
self.toolBox.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored))
self.toolBox.setMinimumWidth(itemWidget.sizeHint().width())
self.toolBox.addItem(itemWidget, "Basic Flowchart Shapes")
self.toolBox.addItem(backgroundWidget, "Backgrounds")
示例11: create_menu_buttons
def create_menu_buttons(self):
# Center on Player Button
button_center_player = QPushButton(
QIcon('maps/graphics/map_menu_center_player.png'),
''
)
button_center_player.setCheckable(True) # Make toggle button
button_center_player.setToolTip('Center on Player')
button_center_player.setObjectName('button_center_player')
# Center on Last Point Button
button_center_point = QPushButton(
QIcon('maps/graphics/map_menu_center_map.png'),
''
)
button_center_point.setCheckable(True) # Make toggle button
button_center_point.setToolTip('Center Normally')
button_center_point.setObjectName('button_center_point')
# Create Button Group for Exclusive Toggling
toggle_group = QButtonGroup(self)
toggle_group.addButton(button_center_player, 1)
toggle_group.addButton(button_center_point, 2)
toggle_group.buttonClicked.connect(self.center_button_toggled)
self.menu.addWidget(button_center_player)
self.menu.addWidget(button_center_point)
# Apply settings for current toggle
if self.settings.get_value('maps', 'center_on') == 'point':
button_center_point.setChecked(True)
else:
button_center_player.setChecked(True)
# Fit to Window Button
button_fit_window = QPushButton(
QIcon('maps/graphics/map_menu_fit_window.png'),
''
)
button_fit_window.setToolTip('Fit Map to Window')
button_fit_window.clicked.connect(self.fit_to_window)
self.menu.addWidget(button_fit_window, 0, Qt.AlignLeft)
# Maps Combo Box
self.combo_load_map = QComboBox(self)
# Need to setView otherwise CSS doesn't work
self.combo_load_map.setView(QListView())
self.combo_load_map.setToolTip('Manually Load Selected Map')
for map_name in sorted(self.map_pairs.keys(), key=str.lower):
self.combo_load_map.addItem(map_name)
self.combo_load_map.currentIndexChanged.connect(
self.load_map_from_combo
)
self.menu.addWidget(self.combo_load_map, 0, Qt.AlignLeft)
示例12: _initUi
def _initUi(self, dlgName):
self.setWindowTitle(dlgName)
allRadioButton = QRadioButton('所有'); allRadioButton.setChecked(True)
highlightRadioButton = QRadioButton('高亮')
# 添加到QButtonGroup
self._buttonGroup = QButtonGroup()
self._buttonGroup.addButton(allRadioButton, 1);
self._buttonGroup.addButton(highlightRadioButton, 2)
cancelPushButton = QPushButton('Cancel')
okPushButton = QPushButton('OK')
cancelPushButton.clicked.connect(self._cancel)
okPushButton.clicked.connect(self._ok)
# 布局
grid = QGridLayout()
grid.setSpacing(10)
grid.addWidget(allRadioButton, 1, 0)
grid.addWidget(highlightRadioButton, 1, 1)
grid.addWidget(okPushButton, 2, 1)
grid.addWidget(cancelPushButton, 2, 0)
self.setLayout(grid)
self.setMinimumWidth(QApplication.desktop().size().width()//5)
示例13: initUI
def initUI(self):
super().initUI()
self.setWindowTitle("ノイズ付与設定")
self.layout = QGridLayout()
self.radioButton1 = QRadioButton("ごま塩ノイズ")
self.radioButton2 = QRadioButton("gaussianノイズ")
self.soltSlider = HorizontalSlider()
self.soltSlider.setTickPosition(QSlider.TicksBelow)
self.soltSlider.setTickInterval(20)
self.gaussSlider = HorizontalSlider()
self.soltTextLine = TextLine(text=str(self.soltSlider.value()),
width=60, readmode=True)
self.gaussTextLine = TextLine(text=str(self.gaussSlider.value()),
width=60, readmode=True)
self.buttonGroup = QButtonGroup()
self.buttonGroup.addButton(self.radioButton1)
self.buttonGroup.addButton(self.radioButton2)
self.soltSlider.valueChanged[int].connect(self.changedSoltSliderValue)
self.gaussSlider.valueChanged[int].connect(self.changedGaussSliderValue)
self.layout.addWidget(self.radioButton1, 0, 0)
self.layout.addWidget(QLabel("ノイズ割合"), 1, 0)
self.layout.addWidget(self.soltSlider, 1, 1)
self.layout.addWidget(self.soltTextLine, 1, 2)
self.layout.addWidget(self.radioButton2, 2, 0)
self.layout.addWidget(QLabel("分散"), 3, 0)
self.layout.addWidget(self.gaussSlider, 3, 1)
self.layout.addWidget(self.gaussTextLine, 3, 2)
self.layout.addWidget(self.btnBox, 4, 2)
self.setLayout(self.layout)
示例14: __init__
def __init__(self):
"""
Constructor
"""
super(HelpViewersPage, self).__init__()
self.setupUi(self)
self.setObjectName("HelpViewersPage")
self.customViewerPicker.setMode(E5PathPickerModes.OpenFileMode)
self.helpViewerGroup = QButtonGroup()
self.helpViewerGroup.addButton(self.helpBrowserButton)
self.helpViewerGroup.addButton(self.qtAssistantButton)
self.helpViewerGroup.addButton(self.webBrowserButton)
self.helpViewerGroup.addButton(self.customViewerButton)
# set initial values
hvId = Preferences.getHelp("HelpViewerType")
if hvId == 1:
self.helpBrowserButton.setChecked(True)
elif hvId == 2:
self.qtAssistantButton.setChecked(True)
elif hvId == 3:
self.webBrowserButton.setChecked(True)
else:
self.customViewerButton.setChecked(True)
self.customViewerPicker.setText(
Preferences.getHelp("CustomViewer"))
示例15: initUI
def initUI(self):
self.winnerButtonGroup = QButtonGroup()
self.nobodyWinnerRadioButton = QRadioButton(self)
self.nobodyWinnerRadioButton.hide()
self.nobodyWinnerRadioButton.setChecked(True)
self.winnerButtonGroup.addButton(self.nobodyWinnerRadioButton)
players = self.engine.getListPlayers()
if len(players) >= 4:
players_grid = True
self.widgetLayout = QGridLayout(self)
else:
players_grid = False
self.widgetLayout = QVBoxLayout(self)
# self.widgetLayout.addStretch()
for np, player in enumerate(players):
self.playerInputList[player] = Phase10PlayerWidget(
player, self.engine, self.winnerButtonGroup, self)
self.playerInputList[player].roundWinnerSet.connect(
self.changedWinner)
if players_grid:
self.widgetLayout.addWidget(
self.playerInputList[player], np/2, np % 2)
else:
self.widgetLayout.addWidget(self.playerInputList[player])