本文整理汇总了Python中PyQt5.QtWidgets.QButtonGroup.buttons方法的典型用法代码示例。如果您正苦于以下问题:Python QButtonGroup.buttons方法的具体用法?Python QButtonGroup.buttons怎么用?Python QButtonGroup.buttons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QButtonGroup
的用法示例。
在下文中一共展示了QButtonGroup.buttons方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ui_Widget
# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import buttons [as 别名]
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')
示例2: initUI
# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import buttons [as 别名]
def initUI(self):
# create menus
menu.GuiMenu()
menu.WidgetMenu()
menu.SettingsMenu()
menu.LoggingMenu()
# main layout
mainVLayout = QVBoxLayout()
elementHLayouts = []
# top element: toolbar, status
t = QLabel("Toolbar")
s = QLabel("Status")
toolbarStatusHLayout = QHBoxLayout()
toolbarStatusHLayout.addWidget(t)
toolbarStatusHLayout.addWidget(s)
elementHLayouts.append(toolbarStatusHLayout)
# mid element: menu buttons
menubuttonsHLayout = QHBoxLayout()
stackedButtonsWidget = QStackedWidget()
buttonGroup = QButtonGroup(self)
buttonGroup.setExclusive(True)
for m in menu.Menu.menus:
btn = QPushButton(m.name)
btn.setCheckable(True)
btn.pressed.connect(lambda m=m: stackedButtonsWidget.setCurrentWidget(m))
menubuttonsHLayout.addWidget(btn)
buttonGroup.addButton(btn)
stackedButtonsWidget.addWidget(m)
elementHLayouts.append(menubuttonsHLayout)
# bot element: menu specific widgets
menuwidgetsHLayout = QHBoxLayout()
menuwidgetsHLayout.addWidget(stackedButtonsWidget)
elementHLayouts.append(menuwidgetsHLayout)
# click first button for defined initial state
if len(buttonGroup.buttons()) > 0:
buttonGroup.buttons()[0].click()
for l in elementHLayouts:
mainVLayout.addLayout(l)
self.setLayout(mainVLayout)
示例3: Ui_Widget
# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import buttons [as 别名]
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 ###
# Slider i LCDNumber ###
self.suwak = QSlider(Qt.Horizontal)
self.suwak.setMinimum(0)
self.suwak.setMaximum(255)
self.lcd = QLCDNumber()
self.lcd.setSegmentStyle(QLCDNumber.Flat)
# układ poziomy (splitter) dla slajdera i lcd
ukladH2 = QSplitter(Qt.Horizontal, self)
ukladH2.addWidget(self.suwak)
ukladH2.addWidget(self.lcd)
ukladH2.setSizes((125, 75))
# przyciski RadioButton ###
self.ukladR = QHBoxLayout()
for v in ('R', 'G', 'B'):
self.radio = QRadioButton(v)
self.ukladR.addWidget(self.radio)
self.ukladR.itemAt(0).widget().setChecked(True)
# grupujemy przyciski
self.grupaRBtn = QGroupBox('Opcje RGB')
self.grupaRBtn.setLayout(self.ukladR)
self.grupaRBtn.setObjectName('Radio')
self.grupaRBtn.setCheckable(True)
# układ poziomy dla grupy Radio
ukladH3 = QHBoxLayout()
ukladH3.addWidget(self.grupaRBtn)
# koniec RadioButton ###
# Lista ComboBox i SpinBox ###
self.listaRGB = QComboBox(self)
for v in ('R', 'G', 'B'):
self.listaRGB.addItem(v)
self.listaRGB.setEnabled(False)
# SpinBox
self.spinRGB = QSpinBox()
self.spinRGB.setMinimum(0)
self.spinRGB.setMaximum(255)
self.spinRGB.setEnabled(False)
# układ pionowy dla ComboBox i SpinBox
uklad = QVBoxLayout()
uklad.addWidget(self.listaRGB)
uklad.addWidget(self.spinRGB)
# do układu poziomego grupy Radio dodajemy układ ComboBox i SpinBox
ukladH3.insertSpacing(1, 25)
ukladH3.addLayout(uklad)
# koniec ComboBox i SpinBox ###
# przyciski PushButton ###
uklad = QHBoxLayout()
self.grupaP = QButtonGroup()
self.grupaP.setExclusive(False)
for v in ('R', 'G', 'B'):
self.btn = QPushButton(v)
self.btn.setCheckable(True)
self.grupaP.addButton(self.btn)
uklad.addWidget(self.btn)
# grupujemy przyciski
self.grupaPBtn = QGroupBox('Przyciski RGB')
self.grupaPBtn.setLayout(uklad)
self.grupaPBtn.setObjectName('Push')
self.grupaPBtn.setCheckable(True)
self.grupaPBtn.setChecked(False)
# koniec PushButton ###
# główny układ okna, wertykalny ###
ukladOkna = QVBoxLayout()
ukladOkna.addLayout(ukladH1)
ukladOkna.addWidget(ukladH2)
ukladOkna.addLayout(ukladH3)
ukladOkna.addWidget(self.grupaPBtn)
#.........这里部分代码省略.........
示例4: ApplicationPage
# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import buttons [as 别名]
#.........这里部分代码省略.........
self._bundle_edit = QCheckBox("Application bundle (OS X)",
whatsThis="Build an application bundle on OS X. If it is not "
"checked then the application will be built as a "
"simple executable.",
stateChanged=self._bundle_changed)
options_layout.addWidget(self._bundle_edit)
options_layout.addStretch()
layout.addLayout(options_layout, 0, 1)
self._package_edit = _ApplicationPackageEditor()
self._package_edit.package_changed.connect(self._package_changed)
package_edit_gb = QGroupBox(self._package_edit.title)
package_edit_gb.setLayout(self._package_edit)
layout.addWidget(package_edit_gb, 1, 0, 1, 2)
layout.setRowStretch(1, 1)
self.setLayout(layout)
def _update_page(self):
""" Update the page using the current project. """
project = self.project
self._name_edit.setText(project.application_name)
self._script_edit.setText(project.application_script)
self._entry_point_edit.setText(project.application_entry_point)
self._sys_path_edit.setText(project.sys_path)
self._package_edit.configure(project.application_package, project)
blocked = self._pyqt_versions_bg.blockSignals(True)
for rb in self._pyqt_versions_bg.buttons():
if rb.text() == 'PyQt5':
rb.setChecked(project.application_is_pyqt5)
else:
rb.setChecked(not project.application_is_pyqt5)
self._pyqt_versions_bg.blockSignals(blocked)
blocked = self._console_edit.blockSignals(True)
self._console_edit.setCheckState(
Qt.Checked if project.application_is_console else Qt.Unchecked)
self._console_edit.blockSignals(blocked)
blocked = self._bundle_edit.blockSignals(True)
self._bundle_edit.setCheckState(
Qt.Checked if project.application_is_bundle else Qt.Unchecked)
self._bundle_edit.blockSignals(blocked)
def _pyqt_version_changed(self, button, checked):
""" Invoked when the user changes the PyQt version number. """
if button.text() == 'PyQt5':
self.project.application_is_pyqt5 = checked
self.project.modified = True
self.pyqt_version_changed.emit(checked)
def _console_changed(self, state):
""" Invoked when the user changes the console state. """
self.project.application_is_console = (state == Qt.Checked)
self.project.modified = True
示例5: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import buttons [as 别名]
#.........这里部分代码省略.........
self.color_tool_bar = self.addToolBar("Color")
self.color_tool_bar.addWidget(self.font_color_tool_button)
self.color_tool_bar.addWidget(self.fill_color_tool_button)
self.color_tool_bar.addWidget(self.line_color_tool_button)
self.loading_tool_bar = self.addToolBar("Load")
self.loading_tool_bar.addAction(self.load_config_action)
pointer_button = QToolButton()
pointer_button.setCheckable(True)
pointer_button.setChecked(True)
pointer_button.setIcon(QIcon(":/images/pointer.png"))
line_pointer_button = QToolButton()
line_pointer_button.setCheckable(True)
line_pointer_button.setIcon(QIcon(":/images/linepointer.png"))
self.pointer_type_group = QButtonGroup()
self.pointer_type_group.addButton(pointer_button, DiagramScene.MoveItem)
self.pointer_type_group.addButton(line_pointer_button, DiagramScene.InsertLine)
self.pointer_type_group.buttonClicked[int].connect(self.pointer_group_clicked)
self.scene_scale_combo = QComboBox()
self.scene_scale_combo.addItems(["50%", "75%", "100%", "125%", "150%"])
self.scene_scale_combo.setCurrentIndex(2)
self.scene_scale_combo.currentIndexChanged[str].connect(self.scene_scale_changed)
self.pointer_tool_bar = self.addToolBar("Pointer type")
self.pointer_tool_bar.addWidget(pointer_button)
self.pointer_tool_bar.addWidget(line_pointer_button)
self.pointer_tool_bar.addWidget(self.scene_scale_combo)
def button_group_clicked(self, button_id):
buttons = self.button_group.buttons()
self.clicked_button_id = button_id
for button in buttons:
if self.button_group.button(button_id) != button:
button.setChecked(False)
if button_id == self.InsertTextButton:
self.scene.set_mode(DiagramScene.InsertText)
else:
self.scene.set_item_type(self.items[button_id])
self.scene.set_mode(DiagramScene.InsertItem)
def delete_item(self):
for item in self.scene.selectedItems():
if isinstance(item, FlumeDiagramItem):
item.remove_arrows()
self.scene.removeItem(item)
# noinspection PyTypeChecker,PyCallByClass
def about(self):
# noinspection PyArgumentList
QMessageBox.about(self, "About Flume Illustrator", "The Flume illustrator shows config-file details")
def pointer_group_clicked(self):
self.scene.set_mode(self.pointer_type_group.checkedId())
def bring_to_front(self):
if not self.scene.selectedItems():
return
selected_item = self.scene.selectedItems()[0]
overlap_items = selected_item.collidingItems()