本文整理汇总了Python中PyQt4.QtGui.QButtonGroup.addButton方法的典型用法代码示例。如果您正苦于以下问题:Python QButtonGroup.addButton方法的具体用法?Python QButtonGroup.addButton怎么用?Python QButtonGroup.addButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QButtonGroup
的用法示例。
在下文中一共展示了QButtonGroup.addButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChooseBlogDialog
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class ChooseBlogDialog(QDialog, Ui_ChooseBlogDialog):
def __init__(self, available_blogs, addToDB):
QDialog.__init__(self)
Ui_ChooseBlogDialog.__init__(self)
self.func = addToDB
self.setupUi(self)
radioboxLayout = QVBoxLayout()
self.radiobuttonGroup = QButtonGroup()
self.radios = []
for blog in available_blogs:
radio = BlogRadio("Blog Title: %s, Url: %s" %(blog.blogname, blog.homeurl), blog)
self.radiobuttonGroup.addButton(radio)
radioboxLayout.addWidget(radio)
self.radios.append(radio)
self.chooseBlogFrame.setLayout(radioboxLayout)
self.adjustSize()
connect(self.chooseBlogButtonBox, SIGNAL("accepted()"), self.addBlog) #AddBlogDialog.accept)
connect(self.chooseBlogButtonBox, SIGNAL("rejected()"), self.reject)#AddBlogDialog.reject)
def addBlog(self):
if self.radiobuttonGroup.checkedButton():
self.func(self.radiobuttonGroup.checkedButton().blog)
self.accept()
else:
QMessageBox.warning(self, "Choose A Blog", "Please choose a blog and click OK. If you do not want to add a blog, Please click 'Cancel'", QMessageBox.Ok, QMessageBox.Ok)
pass
示例2: choice
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def choice(self, title, msg, choices):
vbox = QVBoxLayout()
self.set_layout(vbox)
vbox.addWidget(QLabel(title))
gb2 = QGroupBox(msg)
vbox.addWidget(gb2)
vbox2 = QVBoxLayout()
gb2.setLayout(vbox2)
group2 = QButtonGroup()
for i, c in enumerate(choices):
button = QRadioButton(gb2)
button.setText(c[1])
vbox2.addWidget(button)
group2.addButton(button)
group2.setId(button, i)
if i == 0:
button.setChecked(True)
vbox.addStretch(1)
vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next'))))
if not self.exec_():
return
wallet_type = choices[group2.checkedId()][0]
return wallet_type
示例3: TransformationModule
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class TransformationModule(PreprocessorModule):
DEFAULT_SETTINGS = {
'is_enabled': True,
'method': 0,
}
PorterStemmer, SnowballStemmer, Lemmatizer = 0, 1, 2
transformation_values = {
PorterStemmer: PS,
SnowballStemmer: SS,
Lemmatizer: LM,
}
transformation_method = 0
def __init__(self, data):
data = data or self.DEFAULT_SETTINGS
PreprocessorModule.__init__(
self, 'Stemming', True,
data.get('is_enabled')
)
self.group = QButtonGroup(self, exclusive=True)
for method in [
self.PorterStemmer,
self.SnowballStemmer,
self.Lemmatizer
]:
rb = QRadioButton(
self,
text=self.transformation_values[method].name
)
self.add_to_content_area(rb)
self.group.addButton(rb, method)
self.group.buttonClicked.connect(self.group_button_clicked)
# Restore the previous state, after starting off the layout.
self.restore_data(data)
def group_button_clicked(self):
self.transformation_method = self.group.checkedId()
self.notify_on_change()
def restore_data(self, data):
self.transformation_method = data.get('method')
b = self.group.button(self.transformation_method)
b.setChecked(True)
def export_data(self):
return {
'is_enabled': self.enabled,
'method': self.transformation_method,
}
def get_pp_setting(self):
return {
'transformation': self.transformation_values.get(
self.transformation_method
)
}
示例4: ActionsPane
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class ActionsPane(QWidget):
def __init__(self):
super().__init__()
self.group = QButtonGroup()
self.group.setExclusive(False)
self.scope_widget = ActionsScope()
self.action_buttons = QVBoxLayout()
self.big_red_button = QPushButton("Automate !!!", clicked=self.automate)
self.big_red_button.setStyleSheet("QPushButton { background-color : red}")
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.layout.addWidget(self.scope_widget)
self.layout.addLayout(self.action_buttons)
self.layout.addStretch()
self.layout.addWidget(self.big_red_button)
def registerAction(self, action):
button = ActionButton(action)
self.group.addButton(button.checkbox)
self.action_buttons.addWidget(button)
def getCheckedActions(self):
return [btn.parent().action for btn in self.group.buttons() if btn.isChecked()]
def automate(self, event):
for action in self.getCheckedActions():
action.on_triggered()
示例5: __init__
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def __init__(self, iface_name, parent=None):
IfaceWizardPage.__init__(self, parent)
self.q_netobject = QNetObject.getInstance()
self.setSubTitle("What kind of interface do you want to configure?")
box = QVBoxLayout(self)
self.ethernet = "ethernet", "Activate ethernet interface %s" % iface_name , QRadioButton()
self.vlan = "vlan", "Create a VLAN interface", QRadioButton()
group = QButtonGroup(self)
form = QFormLayout()
options = (self.ethernet, self.vlan)
for item in options:
group.addButton(item[2])
form.addRow(item[1], item[2])
self.registerField(item[0], item[2])
self.ethernet[2].setChecked(Qt.Checked)
box.addLayout(form)
box.addStretch()
box.addWidget(
HelpMissingFunction("""\
All interfaces but one (%s) are configured.
In order to be able to activate an ethernet interface for bonding agregation, \
you must deconfigure at least one ethernet interface first \
(which may be in use by vlans or bondings).""" % iface_name)
)
示例6: TokenizerModule
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class TokenizerModule(PreprocessorModule):
DEFAULT_SETTINGS = {
'is_enabled': True,
'method': 0,
}
NLTKTokenizer, NLTKPunctTokenizer, TwitterTokenizer = 0, 1, 2
tokenizer_values = {
NLTKTokenizer: 'default',
NLTKPunctTokenizer: 'no_punct',
TwitterTokenizer: 'twitter'
}
tokenizer_names = {
NLTKTokenizer: 'NLTK tokenizer',
NLTKPunctTokenizer: 'NLTK tokenizer (no punctuation)',
TwitterTokenizer: 'Twitter tokenizer',
}
tokenizer_method = 0
def __init__(self, data):
data = data or self.DEFAULT_SETTINGS
PreprocessorModule.__init__(
self, 'Tokenizer', False,
data.get('is_enabled')
)
self.group = QButtonGroup(self, exclusive=True)
for method in [
self.NLTKTokenizer,
self.NLTKPunctTokenizer,
self.TwitterTokenizer,
]:
rb = QRadioButton(self, text=self.tokenizer_names[method])
self.add_to_content_area(rb)
self.group.addButton(rb, method)
self.group.buttonClicked.connect(self.group_button_clicked)
# Restore the previous state, after starting off the layout.
self.restore_data(data)
def group_button_clicked(self):
self.tokenizer_method = self.group.checkedId()
self.notify_on_change()
def restore_data(self, data):
self.tokenizer_method = data.get('method')
b = self.group.button(self.tokenizer_method)
b.setChecked(True)
def export_data(self):
return {
'is_enabled': self.enabled,
'method': self.tokenizer_method,
}
def get_pp_setting(self):
return {
'tokenizer': self.tokenizer_values.get(self.tokenizer_method)
}
示例7: RadioBooleanFilter
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class RadioBooleanFilter(QWidget, Control):
""" Boolean filter (Only/Exclude)
"""
def __init__(self, tree, dataset, master, parent=None):
QWidget.__init__(self, parent)
Control.__init__(self, tree, dataset, master)
self.setLayout(QVBoxLayout())
self.buttonGroup = QButtonGroup(self)
self.values = []
for i, option in enumerate(tree.subelements_top("Option")):
rb = QRadioButton(option.displayName, self)
self.buttonGroup.addButton(rb)
self.buttonGroup.setId(rb, i)
self.layout().addWidget(rb)
self.values.append(option.value)
self.buttonGroup.button(0).setChecked(True)
def value(self):
return {"excluded": "%i" % self.buttonGroup.checkedId()}
def get_filter(self):
return self.tree.internalName, self.value()
def query(self):
return [("Filter", self.tree, self.value())]
def setControlValue(self, name, value):
for i, v in enumerate(self.values):
if v == value:
button = self.buttonGroup.button(i)
button.setChecked(True)
break
示例8: ScopeBox
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class ScopeBox(QGroupBox):
title = None
button_type = None
def __init__(self):
if self.title is None or self.button_type is None:
raise Exception("Still too abstract!")
super().__init__(title=self.title)
self.populate_button_id()
self.build_layout()
self.populate_box()
self.select_default()
if self.button_type == 'check':
self.group.setExclusive(False)
def populate_button_id(self):
pass
def build_layout(self):
self.group = QButtonGroup()
self.layout = QVBoxLayout()
self.setLayout(self.layout)
def populate_box(self):
keys = list(self.button_id.keys())
keys.sort()
BtnClass = None
if self.button_type == 'check':
BtnClass = QCheckBox
elif self.button_type == 'radio':
BtnClass = QRadioButton
for key in keys:
btn = BtnClass(key)
self.layout.addWidget(btn)
self.group.addButton(btn, self.button_id[key])
def select_default(self):
pass
def getSelection(self):
selection = None
if self.button_type == 'radio':
selection = self.group.checkedId()
elif self.button_type == 'check':
selection = []
for btn in self.group.buttons():
if btn.isChecked():
selection.append(btn.text())
return selection
示例9: AxisWidgetContainer
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class AxisWidgetContainer(GridWidget):
def __init__(self, axisModel, parent = None):
super(AxisWidgetContainer, self).__init__(["_Axis", "_Value_", "_X(24)", "_Y(24)"], parent)
self.axisModel = axisModel
self.xGroup = QButtonGroup()
self.yGroup = QButtonGroup()
self.xGroup.buttonClicked.connect(self.showXAxisButtonClicked)
self.yGroup.buttonClicked.connect(self.showYAxisButtonClicked)
axis = 0
for axis in range(axisModel.currentJoystickNumAxes()):
self.__createTextWidgetForAxis__(axis)
if axis > 0:
self.graphWidget = AxisGraphWidget(self)
self.addWidget(self.graphWidget, 3, 0, 1, 2)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.scrollArea.sizePolicy().hasHeightForWidth())
self.scrollArea.setSizePolicy(sizePolicy)
def __createTextWidgetForAxis__(self, axis):
textWidget = AxisTextWidget(axis, self)
self.axisModel.addAxisObserver(textWidget, axis)
showInX = QRadioButton()
showInY = QRadioButton()
showInX.setObjectName(str(axis))
showInY.setObjectName(str(axis))
showInX.setLayoutDirection(Qt.RightToLeft)
showInY.setLayoutDirection(Qt.RightToLeft)
showInX.setMaximumSize(24, 24)
showInY.setMaximumSize(24, 24)
self.xGroup.addButton(showInX)
self.yGroup.addButton(showInY)
gridLayout = QGridLayout()
gridLayout.addWidget(textWidget, 0, 0, 1, 2)
gridLayout.addWidget(showInX, 0, 2, 1, 1)
gridLayout.addWidget(showInY, 0, 3, 1, 1)
self.addLayoutToScrollArea(gridLayout)
def showXAxisButtonClicked(self, button):
if button.isChecked():
self.graphWidget.setXAxis(int(button.objectName()))
self.axisModel.addAxisObserver(self.graphWidget, int(button.objectName()))
else:
self.axisModel.removeAxisObserver(self.graphWidget, int(button.objectName()))
def showYAxisButtonClicked(self, button):
if button.isChecked():
self.graphWidget.setYAxis(int(button.objectName()))
self.axisModel.addAxisObserver(self.graphWidget, int(button.objectName()))
else:
self.axisModel.removeAxisObserver(self.graphWidget, int(button.objectName()))
示例10: __init__
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def __init__(self):
super(IntroductionPage, self).__init__()
self.setTitle(self.tr("Creación de un nuevo Proyecto"))
self.setSubTitle(self.tr("Información básica del Proyecto"))
container = QVBoxLayout(self)
hbox = QHBoxLayout()
# Nombre
hbox.addWidget(QLabel(self.tr("Nombre del Proyecto:")))
self.line_name = QLineEdit()
hbox.addWidget(self.line_name)
container.addLayout(hbox)
# Ubicación
group = QGroupBox(self.tr("Ubicación:"))
box = QVBoxLayout(group)
button_group = QButtonGroup(self)
radio_buttons = [
self.tr("Directorio por defecto"),
self.tr("Otro")
]
for _id, radiob in enumerate(radio_buttons):
radio_button = QRadioButton(radiob)
button_group.addButton(radio_button, _id)
box.addWidget(radio_button)
if _id == 0:
# El primero checked por defecto
radio_button.setChecked(True)
container.addWidget(group)
self.line_location = QLineEdit()
container.addWidget(self.line_location)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(self.tr("Archivo del Proyecto: ")))
self._project_filename = QLineEdit()
hbox.addWidget(self._project_filename)
container.addLayout(hbox)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(self.tr("Archivo resultante: ")))
self._resulting_filename = QLineEdit()
hbox.addWidget(self._resulting_filename)
container.addLayout(hbox)
# Conexiones
self.connect(button_group, SIGNAL("buttonClicked(int)"),
self._update_location)
self.connect(self.line_name, SIGNAL("textChanged(const QString&)"),
self._on_project_name_changed)
self.connect(self.line_name, SIGNAL("textChanged(const QString&)"),
lambda: self.emit(SIGNAL("completeChanged()")))
self._update_location(0)
示例11: __init__
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def __init__(self, model, key, radiobuttonswithvalues):
Mapping.__init__(self, model, key)
self.radiobuttonswithvalues = radiobuttonswithvalues
buttongroup = None
for radiobutton, correspondingvalue in self.radiobuttonswithvalues.items():
# Tiresome extra setup to ensure that exactly one button is ever checked
if buttongroup is None:
buttongroup = QButtonGroup(radiobutton.parent())
buttongroup.addButton(radiobutton)
# NB: default-argument indirection below to solve closure capture issues
radiobutton.connect(radiobutton, SIGNAL("clicked()"), lambda cv=correspondingvalue: self.updateModelValue(cv))
示例12: add_node
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def add_node(self, parentItem, path, type):
item = QTreeWidgetItem(parentItem)
item.setText(0, path_leaf(path))
buttonGroup = QButtonGroup()
isNewFile = type is "UNTRACKED"
isModifiedFile = type is "MODIFIED"
isMissing = type is "MISSING"
isDirectory = type is "DIR"
if isNewFile:
item.setText(1, type)
item.setForeground(1, QBrush(QColor(0, 255, 0)))
if isModifiedFile:
item.setText(1, type)
item.setForeground(1, QBrush(QColor(0, 0, 255)))
if isMissing:
item.setText(1, type)
item.setForeground(1, QBrush(QColor(255, 0, 0)))
if isDirectory:
for i in range(self.tree.columnCount()):
item.setBackground(i, QBrush(QColor(230, 230, 255)))
# must keep reference to buttonGroup for its callback to work
parent_data = self.retrieve_data(parentItem)
if parent_data != None:
path = os.path.join(parent_data[0], path)
self.attach_data(item, (path, buttonGroup, type))
for i in range(self.uncheckableColumns, self.tree.columnCount()):
if i == self.tree.columnCount() - 7 and isMissing:
continue # option to add not enabled for missing files
if i == self.tree.columnCount() - 4 and isNewFile:
continue # option to resolve not enabled for new files
if i == self.tree.columnCount() - 3 and not isMissing:
continue # option to stop tracking enabled only for missing files
if i == self.tree.columnCount() - 2 and not isNewFile:
continue # option to delete enabled only for untracked files
if i == self.tree.columnCount() - 2 and isDirectory:
continue # option to delete not enabled for directories, too dangerous
button = QRadioButton()
buttonGroup.addButton(button, i - self.uncheckableColumns) # id is the index
button.treeItem = item
self.tree.setItemWidget(item, i, button)
buttonGroup.buttonClicked.connect(self.tree_item_radio_clicked)
return item
示例13: __init__
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def __init__(self, parent = None):
super(StrokeStyleWidget, self).__init__(parent)
self.setupUi(self)
capGroup = QButtonGroup(self)
capGroup.addButton(self.squareCapButton, Qt.SquareCap)
capGroup.addButton(self.roundCapButton, Qt.RoundCap)
capGroup.addButton(self.flatCapButton, Qt.FlatCap)
capGroup.setExclusive(True)
capGroup.buttonClicked[int].connect(self.capStyleChanged)
joinGroup = QButtonGroup(self)
joinGroup.addButton(self.roundJoinButton, Qt.RoundJoin)
joinGroup.addButton(self.miterJoinButton, Qt.MiterJoin)
joinGroup.addButton(self.bevelJoinButton, Qt.BevelJoin)
joinGroup.setExclusive(True)
joinGroup.buttonClicked[int].connect(self.joinStyleChanged)
self.widthSpinner.valueChanged.connect(self.strokeWidthChanged)
示例14: CategoryButtons
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
class CategoryButtons(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
Layout = QHBoxLayout(self)
self.group = QButtonGroup(self)
for i, (k, color) in enumerate(ORDERED):
button = QPushButton(k)
palette = QPalette(button.palette())
palette.setColor(QPalette.Button, color)
button.setPalette(palette)
self.group.addButton(button)
self.group.setId(button, i)
Layout.addWidget(button)
QObject.connect(self.group,
SIGNAL('buttonClicked(QAbstractButton *)'),
self.clicked)
def clicked(self, button):
category = ORDERED[self.group.id(button)][0]
self.emit(SIGNAL('selected(QString &)'), category)
示例15: __init__
# 需要导入模块: from PyQt4.QtGui import QButtonGroup [as 别名]
# 或者: from PyQt4.QtGui.QButtonGroup import addButton [as 别名]
def __init__(self, result):
QDialog.__init__(self)
self.layout = QVBoxLayout(self)
self.result = result
observation_window = result.observation_window
group = QButtonGroup(self)
use_simu_duration = QRadioButton("Use entire simulation.")
use_simu_duration.setChecked(
observation_window[0] == 0
and observation_window[1] == result.model.duration)
group.addButton(use_simu_duration)
self.layout.addWidget(use_simu_duration)
use_custom = QRadioButton("Use a custom observation window:")
use_custom.setChecked(not use_simu_duration.isChecked())
group.addButton(use_custom)
self.layout.addWidget(use_custom)
self._slider = QxtSpanSliderWidget(
0, result.model.now() // result.model.cycles_per_ms, self)
self._slider.setSpan(
observation_window[0] // result.model.cycles_per_ms,
observation_window[1] // result.model.cycles_per_ms)
self._slider.setEnabled(use_custom.isChecked())
group.buttonClicked.connect(
lambda x: self._slider.setEnabled(x == use_custom))
self.layout.addWidget(self._slider)
buttons = QWidget(self)
buttons_layout = QHBoxLayout()
buttons.setLayout(buttons_layout)
buttons_layout.addStretch()
ok_button = QPushButton("Ok")
cancel_button = QPushButton("Cancel")
ok_button.clicked.connect(self.accept)
cancel_button.clicked.connect(self.reject)
buttons_layout.addWidget(ok_button)
buttons_layout.addWidget(cancel_button)
self.layout.addWidget(buttons)