def generate_q_double_spin_box(default_val, range_min, range_max, decimals,
                               single_step):
    spin_box = QDoubleSpinBox()
    spin_box.setValue(default_val)
    spin_box.setRange(range_min, range_max)
    spin_box.setDecimals(decimals)
    spin_box.setSingleStep(single_step)
    #spin_box.valueChanged[unicode].connect(self.callback_spin_box)
    return spin_box
예제 #2
0
 def createEditor(self, parent, option, index):
     '''
     Creates a editor in the TreeView depending on type of the settings data.
     '''
     item = self._itemFromIndex(index)
     if item.edit_type() == SettingsValueItem.EDIT_TYPE_AUTODETECT:
         if isinstance(item.value(), bool):
             box = QCheckBox(parent)
             box.setFocusPolicy(Qt.StrongFocus)
             box.setAutoFillBackground(True)
             box.stateChanged.connect(self.edit_finished)
             return box
         elif isinstance(item.value(), int):
             box = QSpinBox(parent)
             box.setValue(item.value())
             if not item.value_min() is None:
                 box.setMinimum(item.value_min())
             if not item.value_max() is None:
                 box.setMaximum(item.value_max())
             if not item.value_step() is None:
                 box.setSingleStep(item.value_step())
             return box
         elif isinstance(item.value(), float):
             box = QDoubleSpinBox(parent)
             box.setValue(item.value())
             if not item.value_min() is None:
                 box.setMinimum(item.value_min())
             if not item.value_max() is None:
                 box.setMaximum(item.value_max())
             if not item.value_step() is None:
                 box.setSingleStep(item.value_step())
             box.setDecimals(3)
             return box
     elif item.edit_type() == SettingsValueItem.EDIT_TYPE_FOLDER:
         editor = PathEditor(item.value(), parent)
         editor.editing_finished_signal.connect(self.edit_finished)
         return editor
     elif item.edit_type() == SettingsValueItem.EDIT_TYPE_LIST:
         box = QComboBox(parent)
         box.addItems(item.value_list())
         index = box.findText(item.value())
         if index >= 0:
             box.setCurrentIndex(index)
         box.setEditable(False)
         return box
     return QStyledItemDelegate.createEditor(self, parent, option, index)
예제 #3
0
 def createEditor(self, parent, option, index):
     editor = QDoubleSpinBox(parent)
     editor.setDecimals(self._decimals)
     editor.setMaximum(self._min)
     editor.setMaximum(self._max)
     return editor