def _create_radiobutton_panel(self, input_data): panel = self._create_group_panel(input_data) layout = panel.layout() items = input_data['data_type'] default_value = input_data.get('default_value') self._ui.inputWidget = buttongroup = Qt.QButtonGroup() buttongroup.setExclusive(True) for item in items: is_seq = not isinstance(item, string_types) and \ isinstance(item, collections.Sequence) if is_seq: text, userData = item else: text, userData = str(item), item button = Qt.QRadioButton(text) button._value = userData if default_value == userData: button.setChecked(True) buttongroup.addButton(button) layout.addWidget(button) return panel, self._get_radiobutton_value
def _build(self): """_build(self) -> None Builds this widget sub-items""" l = self.layout() l.setSpacing(0) l.setMargin(0) id = self.getIntDigitCount() dd = self.getDecDigitCount() digits = self.getDigitCount() self._upButtons = Qt.QButtonGroup() self._downButtons = Qt.QButtonGroup() self._digitLabels = [] for l in self._digitLabels: l.setAlignment(Qt.AlignCenter) showDot = self.getDecDigitCount() > 0 signLabel = _DigitLabel('+') signLabel.setFocusPolicy(Qt.Qt.NoFocus) signLabel.setAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignVCenter) self._digitLabels.append(signLabel) l.addWidget(signLabel, 1, 0) l.setRowMinimumHeight(1, signLabel.minimumSizeHint().height()) l.setColumnMinimumWidth(0, _ArrowButton.ButtonSize) l.setColumnStretch(0, 1) for i in xrange(id): col = i + 1 d = _DigitLabel('0') up = _UpArrowButton(id - i - 1) down = _DownArrowButton(id - i - 1) d.setButtons(up, down) up.setFocusProxy(d) down.setFocusProxy(d) self._upButtons.addButton(up, col) self._downButtons.addButton(down, col) self._digitLabels.append(d) if self.getShowArrowButtons(): l.addWidget(up, 0, col) l.addWidget(down, 2, col) l.addWidget(d, 1, col) if showDot: dotLabel = _DigitLabel('.') dotLabel.setFocusPolicy(Qt.Qt.NoFocus) dotLabel.setAlignment(Qt.Qt.AlignCenter) self._digitLabels.append(dotLabel) l.addWidget(dotLabel, 1, id + 1) for i in xrange(id, digits): col = i + 1 if showDot: col += 1 d = _DigitLabel('0') up = _UpArrowButton(id - i - 1) down = _DownArrowButton(id - i - 1) d.setButtons(up, down) up.setFocusProxy(d) down.setFocusProxy(d) self._upButtons.addButton(up, col) self._downButtons.addButton(down, col) self._digitLabels.append(d) if self.getShowArrowButtons(): l.addWidget(up, 0, col) l.addWidget(down, 2, col) l.addWidget(d, 1, col) self._upButtons.buttonClicked.connect(self.buttonPressed) self._downButtons.buttonClicked.connect(self.buttonPressed) ed = _NumericEditor(self) ed.returnPressed.connect(self.editingFinished) ed.lostFocus.connect(ed.hide) rect = Qt.QRect(l.cellRect(1, 0).topLeft(), l.cellRect(1, l.columnCount() - 1).bottomRight()) ed.setGeometry(rect) ed.setAlignment(Qt.Qt.AlignRight) ed.validator().setRange(self.getMinValue(), self.getMaxValue(), self.getDecDigitCount()) ed.setVisible(False) self._editor = ed self.clearWarning()