예제 #1
0
    def createEditor(self, parent):
        if isinstance(self._value, int):
            sb = QSpinBox(parent)
        elif isinstance(self._value, float):
            sb = QDoubleSpinBox(parent)
            sb.setDecimals(self.decimals)

        sb.setMinimum(self.min)
        sb.setMaximum(self.max)
        sb.setValue(self._value)
        sb.setFrame(False)
        return sb
예제 #2
0
파일: api.py 프로젝트: hlouzada/spyder
 def create_spinbox(self,
                    prefix,
                    suffix,
                    option,
                    default=NoDefault,
                    min_=None,
                    max_=None,
                    step=None,
                    tip=None,
                    section=None):
     if section is not None and section != self.CONF_SECTION:
         self.cross_section_options[option] = section
     widget = QWidget(self)
     if prefix:
         plabel = QLabel(prefix)
         widget.plabel = plabel
     else:
         plabel = None
     if suffix:
         slabel = QLabel(suffix)
         widget.slabel = slabel
     else:
         slabel = None
     if step is not None:
         if type(step) is int:
             spinbox = QSpinBox()
         else:
             spinbox = QDoubleSpinBox()
             spinbox.setDecimals(1)
         spinbox.setSingleStep(step)
     else:
         spinbox = QSpinBox()
     if min_ is not None:
         spinbox.setMinimum(min_)
     if max_ is not None:
         spinbox.setMaximum(max_)
     if tip is not None:
         spinbox.setToolTip(tip)
     self.spinboxes[spinbox] = (section, option, default)
     layout = QHBoxLayout()
     for subwidget in (plabel, spinbox, slabel):
         if subwidget is not None:
             layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget.spinbox = spinbox
     widget.setLayout(layout)
     return widget
예제 #3
0
    def createEditor(self, parent):
        w = QWidget(parent)
        l = QHBoxLayout()
        l.setSpacing(0)
        l.setContentsMargins(0, 0, 0, 0)
        for v in self._value:
            if isinstance(v, int):
                sb = QSpinBox()
            elif isinstance(v, float):
                sb = QDoubleSpinBox()
                sb.setDecimals(self.decimals)

            sb.setMinimum(self.min)
            sb.setMaximum(self.max)
            sb.setValue(v)
            sb.setFrame(False)

            l.addWidget(sb)

        w.setLayout(l)
        return w
예제 #4
0
 def create_spinbox(self, prefix, suffix, option, default=NoDefault,
                    min_=None, max_=None, step=None, tip=None):
     widget = QWidget(self)
     if prefix:
         plabel = QLabel(prefix)
         widget.plabel = plabel
     else:
         plabel = None
     if suffix:
         slabel = QLabel(suffix)
         widget.slabel = slabel
     else:
         slabel = None
     if step is not None:
         if type(step) is int:
             spinbox = QSpinBox()
         else:
             spinbox = QDoubleSpinBox()
             spinbox.setDecimals(1)
         spinbox.setSingleStep(step)
     else:
         spinbox = QSpinBox()
     if min_ is not None:
         spinbox.setMinimum(min_)
     if max_ is not None:
         spinbox.setMaximum(max_)
     if tip is not None:
         spinbox.setToolTip(tip)
     self.spinboxes[spinbox] = (option, default)
     layout = QHBoxLayout()
     for subwidget in (plabel, spinbox, slabel):
         if subwidget is not None:
             layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget.spinbox = spinbox
     widget.setLayout(layout)
     return widget