本文整理汇总了Python中PyQt4.QtGui.QDoubleSpinBox.singleStep方法的典型用法代码示例。如果您正苦于以下问题:Python QDoubleSpinBox.singleStep方法的具体用法?Python QDoubleSpinBox.singleStep怎么用?Python QDoubleSpinBox.singleStep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QDoubleSpinBox
的用法示例。
在下文中一共展示了QDoubleSpinBox.singleStep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import singleStep [as 别名]
def __init__(self, parameter, parent=None):
"""Constructor.
:param parameter: A GroupSelectParameter object.
:type parameter: GroupSelectParameter
"""
QWidget.__init__(self, parent)
self._parameter = parameter
# Store spin box
self.spin_boxes = {}
# Create elements
# Label (name)
self.label = QLabel(self._parameter.name)
# Layouts
self.main_layout = QVBoxLayout()
self.input_layout = QVBoxLayout()
# _inner_input_layout must be filled with widget in the child class
self.inner_input_layout = QVBoxLayout()
self.radio_button_layout = QGridLayout()
# Create radio button group
self.input_button_group = QButtonGroup()
# List widget
self.list_widget = QListWidget()
self.list_widget.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.list_widget.setDragDropMode(QAbstractItemView.DragDrop)
self.list_widget.setDefaultDropAction(Qt.MoveAction)
self.list_widget.setEnabled(False)
self.list_widget.setSizePolicy(
QSizePolicy.Maximum, QSizePolicy.Expanding)
for i, key in enumerate(self._parameter.options):
value = self._parameter.options[key]
radio_button = QRadioButton(value.get('label'))
self.radio_button_layout.addWidget(radio_button, i, 0)
if value.get('type') == SINGLE_DYNAMIC:
double_spin_box = QDoubleSpinBox()
self.radio_button_layout.addWidget(double_spin_box, i, 1)
double_spin_box.setValue(value.get('value', 0))
double_spin_box.setMinimum(
value.get('constraint', {}).get('min', 0))
double_spin_box.setMaximum(value.get(
'constraint', {}).get('max', 1))
double_spin_box.setSingleStep(
value.get('constraint', {}).get('step', 0.01))
step = double_spin_box.singleStep()
if step > 1:
precision = 0
else:
precision = len(str(step).split('.')[1])
if precision > 3:
precision = 3
double_spin_box.setDecimals(precision)
self.spin_boxes[key] = double_spin_box
# Enable spin box depends on the selected option
if self._parameter.selected == key:
double_spin_box.setEnabled(True)
else:
double_spin_box.setEnabled(False)
elif value.get('type') == STATIC:
static_value = value.get('value', 0)
if static_value is not None:
self.radio_button_layout.addWidget(
QLabel(str(static_value)), i, 1)
elif value.get('type') == MULTIPLE_DYNAMIC:
selected_fields = value.get('value', [])
if self._parameter.selected == key:
self.list_widget.setEnabled(True)
else:
self.list_widget.setEnabled(False)
self.input_button_group.addButton(radio_button, i)
if self._parameter.selected == key:
radio_button.setChecked(True)
# Help text
self.help_label = QLabel(self._parameter.help_text)
self.help_label.setSizePolicy(
QSizePolicy.Maximum, QSizePolicy.Expanding)
self.help_label.setWordWrap(True)
self.help_label.setAlignment(Qt.AlignTop)
self.inner_input_layout.addLayout(self.radio_button_layout)
self.inner_input_layout.addWidget(self.list_widget)
# Put elements into layouts
self.input_layout.addWidget(self.label)
self.input_layout.addLayout(self.inner_input_layout)
self.help_layout = QVBoxLayout()
self.help_layout.addWidget(self.help_label)
#.........这里部分代码省略.........