我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用PySide.QtGui.QRadioButton()。
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)
def filesUI(self): move = QtGui.QRadioButton("Move") copy = QtGui.QRadioButton("Copy") rename = QtGui.QRadioButton("Rename") pass
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(186, 154) Form.setMaximumSize(QtCore.QSize(200, 16777215)) self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName("gridLayout") self.label = QtGui.QLabel(Form) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 7, 0, 1, 2) self.linkCombo = QtGui.QComboBox(Form) self.linkCombo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) self.linkCombo.setObjectName("linkCombo") self.gridLayout.addWidget(self.linkCombo, 7, 2, 1, 2) self.autoPercentSpin = QtGui.QSpinBox(Form) self.autoPercentSpin.setEnabled(True) self.autoPercentSpin.setMinimum(1) self.autoPercentSpin.setMaximum(100) self.autoPercentSpin.setSingleStep(1) self.autoPercentSpin.setProperty("value", 100) self.autoPercentSpin.setObjectName("autoPercentSpin") self.gridLayout.addWidget(self.autoPercentSpin, 2, 2, 1, 2) self.autoRadio = QtGui.QRadioButton(Form) self.autoRadio.setChecked(True) self.autoRadio.setObjectName("autoRadio") self.gridLayout.addWidget(self.autoRadio, 2, 0, 1, 2) self.manualRadio = QtGui.QRadioButton(Form) self.manualRadio.setObjectName("manualRadio") self.gridLayout.addWidget(self.manualRadio, 1, 0, 1, 2) self.minText = QtGui.QLineEdit(Form) self.minText.setObjectName("minText") self.gridLayout.addWidget(self.minText, 1, 2, 1, 1) self.maxText = QtGui.QLineEdit(Form) self.maxText.setObjectName("maxText") self.gridLayout.addWidget(self.maxText, 1, 3, 1, 1) self.invertCheck = QtGui.QCheckBox(Form) self.invertCheck.setObjectName("invertCheck") self.gridLayout.addWidget(self.invertCheck, 5, 0, 1, 4) self.mouseCheck = QtGui.QCheckBox(Form) self.mouseCheck.setChecked(True) self.mouseCheck.setObjectName("mouseCheck") self.gridLayout.addWidget(self.mouseCheck, 6, 0, 1, 4) self.visibleOnlyCheck = QtGui.QCheckBox(Form) self.visibleOnlyCheck.setObjectName("visibleOnlyCheck") self.gridLayout.addWidget(self.visibleOnlyCheck, 3, 2, 1, 2) self.autoPanCheck = QtGui.QCheckBox(Form) self.autoPanCheck.setObjectName("autoPanCheck") self.gridLayout.addWidget(self.autoPanCheck, 4, 2, 1, 2) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def tabGeneral(self): self.patherror = QtGui.QLabel('') self.objecterror = QtGui.QLabel('') self.filePath = QtGui.QLineEdit('') self.connect(self.filePath, QtCore.SIGNAL("textChanged (const QString&)"), self.changePathFInfo) self.filePath.setText(os.path.join(os.path.expanduser("~"), 'Unnamed.inc')) self.filePath.setReadOnly(True) self.objectName = QtGui.QLineEdit('') changePath = QtGui.QPushButton('...') changePath.setFixedWidth(30) self.connect(changePath, QtCore.SIGNAL("clicked ()"), self.changePathF) generalBox = QtGui.QGroupBox(u'General') generalBoxLay = QtGui.QGridLayout(generalBox) generalBoxLay.addWidget(QtGui.QLabel(u'Path '), 0, 0, 1, 1) generalBoxLay.addWidget(self.filePath, 0, 1, 1, 2) generalBoxLay.addWidget(changePath, 0, 3, 1, 1) generalBoxLay.addWidget(self.patherror, 1, 0, 1, 4) generalBoxLay.addWidget(QtGui.QLabel(u'Object name '), 2, 0, 1, 1) generalBoxLay.addWidget(self.objectName, 2, 1, 1, 3) generalBoxLay.addWidget(self.objecterror, 3, 0, 1, 4) generalBoxLay.setColumnStretch(1, 10) # self.exportObjects_All = QtGui.QRadioButton(u'All visible objects') self.exportObjects_All.setChecked(True) self.exportObjects_Selected = QtGui.QRadioButton(u'All selected objects') self.exportObjects_SelectedFaces = QtGui.QRadioButton(u'All selected faces') self.exportObjects_SelectedFaces.setDisabled(True) exportObjectsBox = QtGui.QGroupBox(u'Export objects') exportObjectsBoxLay = QtGui.QVBoxLayout(exportObjectsBox) exportObjectsBoxLay.addWidget(self.exportObjects_All) exportObjectsBoxLay.addWidget(self.exportObjects_Selected) exportObjectsBoxLay.addWidget(self.exportObjects_SelectedFaces) ##### widget = QtGui.QWidget() lay = QtGui.QGridLayout(widget) lay.addWidget(generalBox, 0, 0, 1, 4) lay.addWidget(separator(), 1, 0, 1, 4) lay.addWidget(exportObjectsBox, 2, 0, 1, 4) lay.setRowStretch(10, 10) return widget