Exemplo n.º 1
0
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.start_spinbox = QtGui.QSpinBox()
        self.end_spinbox = QtGui.QSpinBox()
        self.slider = QSpanSlider(QtCore.Qt.Horizontal)

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractIntRangeWidget.__init__(self)

        # To be compatible with tree or table views, slider must keep focus
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumHeight(22)
        self.start_spinbox.setMinimumHeight(18)
        self.end_spinbox.setMinimumHeight(18)
        self.slider.setMinimumHeight(18)

        self.slider.lowerPositionChanged.connect(self.start_spinbox.setValue)
        self.slider.lowerPositionChanged.connect(self.end_spinbox.setMinimum)
        self.slider.upperPositionChanged.connect(self.end_spinbox.setValue)
        self.slider.upperPositionChanged.connect(self.start_spinbox.setMaximum)

        self.start_spinbox.valueChanged.connect(self.slider.setLowerValue)
        self.end_spinbox.valueChanged.connect(self.slider.setUpperValue)

        self.start_spinbox.valueChanged.connect(self.end_spinbox.setMinimum)
        self.end_spinbox.valueChanged.connect(self.start_spinbox.setMaximum)
        self.start_spinbox.valueChanged.connect(
            self.notify_start_value_changed)
        self.end_spinbox.valueChanged.connect(self.notify_end_value_changed)

        self.slider.spanChanged.connect(self.notify_value_changed)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.start_spinbox)
        layout.addWidget(self.slider)
        layout.addWidget(self.end_spinbox)

        self.value_changed_signal = self.valueChanged
Exemplo n.º 2
0
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.start_spinbox = QtGui.QSpinBox()
        self.end_spinbox = QtGui.QSpinBox()
        self.slider = QSpanSlider(QtCore.Qt.Horizontal)

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractIntRangeWidget.__init__(self)

        # To be compatible with tree or table views, slider must keep focus
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumHeight(22)
        self.start_spinbox.setMinimumHeight(18)
        self.end_spinbox.setMinimumHeight(18)
        self.slider.setMinimumHeight(18)

        self.slider.lowerPositionChanged.connect(self.start_spinbox.setValue)
        self.slider.lowerPositionChanged.connect(self.end_spinbox.setMinimum)
        self.slider.upperPositionChanged.connect(self.end_spinbox.setValue)
        self.slider.upperPositionChanged.connect(self.start_spinbox.setMaximum)

        self.start_spinbox.valueChanged.connect(self.slider.setLowerValue)
        self.end_spinbox.valueChanged.connect(self.slider.setUpperValue)

        self.start_spinbox.valueChanged.connect(self.end_spinbox.setMinimum)
        self.end_spinbox.valueChanged.connect(self.start_spinbox.setMaximum)
        self.start_spinbox.valueChanged.connect(self.notify_start_value_changed)
        self.end_spinbox.valueChanged.connect(self.notify_end_value_changed)

        self.slider.spanChanged.connect(self.notify_value_changed)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.start_spinbox)
        layout.addWidget(self.slider)
        layout.addWidget(self.end_spinbox)

        self.value_changed_signal = self.valueChanged
Exemplo n.º 3
0
class IntRangeSlider(QtGui.QWidget, AbstractIntRangeWidget):
    valueChanged = QtCore.Signal(tuple)

    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.start_spinbox = QtGui.QSpinBox()
        self.end_spinbox = QtGui.QSpinBox()
        self.slider = QSpanSlider(QtCore.Qt.Horizontal)

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractIntRangeWidget.__init__(self)

        # To be compatible with tree or table views, slider must keep focus
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumHeight(22)
        self.start_spinbox.setMinimumHeight(18)
        self.end_spinbox.setMinimumHeight(18)
        self.slider.setMinimumHeight(18)

        self.slider.lowerPositionChanged.connect(self.start_spinbox.setValue)
        self.slider.lowerPositionChanged.connect(self.end_spinbox.setMinimum)
        self.slider.upperPositionChanged.connect(self.end_spinbox.setValue)
        self.slider.upperPositionChanged.connect(self.start_spinbox.setMaximum)

        self.start_spinbox.valueChanged.connect(self.slider.setLowerValue)
        self.end_spinbox.valueChanged.connect(self.slider.setUpperValue)

        self.start_spinbox.valueChanged.connect(self.end_spinbox.setMinimum)
        self.end_spinbox.valueChanged.connect(self.start_spinbox.setMaximum)
        self.start_spinbox.valueChanged.connect(
            self.notify_start_value_changed)
        self.end_spinbox.valueChanged.connect(self.notify_end_value_changed)

        self.slider.spanChanged.connect(self.notify_value_changed)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.start_spinbox)
        layout.addWidget(self.slider)
        layout.addWidget(self.end_spinbox)

        self.value_changed_signal = self.valueChanged

    def reset(self, value=(0, 255), minimum=None, maximum=None, **kwargs):
        if minimum is not None:
            self.slider.setMinimum(minimum)
            self.start_spinbox.setMinimum(minimum)
        if maximum is not None:
            self.slider.setMaximum(maximum)
            self.end_spinbox.setMaximum(maximum)
        self.start_spinbox.setMaximum(value[1])
        self.end_spinbox.setMinimum(value[0])

        self.setValue(value)

    def apply(self, control):
        AbstractQtControlWidget.apply(self, control)
        control.interface.min = self.slider.minimum()
        control.interface.max = self.slider.maximum()
        control.value = self.value()

    def value(self, interface=None):
        return (self.slider.lowerValue(), self.slider.upperValue())

    def setValue(self, value):
        self.slider.setSpan(value[0], value[1])
        self.start_spinbox.setValue(value[0])
        self.start_spinbox.setMaximum(value[1])
        self.end_spinbox.setValue(value[1])
        self.end_spinbox.setMinimum(value[0])

    def notify_value_changed(self, lower_value, upper_value):
        self.valueChanged.emit((lower_value, upper_value))

    def notify_start_value_changed(self, value):
        self.valueChanged.emit((value, self.end_spinbox.value()))

    def notify_end_value_changed(self, value):
        self.valueChanged.emit((self.start_spinbox.value(), value))
Exemplo n.º 4
0
 def __init__(self):
     QSpanSlider.__init__(self)
     AbstractIntRangeWidget.__init__(self)
     self.spanChanged.connect(self.notify_value_changed)
     self.value_changed_signal = self.valueChanged
Exemplo n.º 5
0
class IntRangeSlider(QtGui.QWidget, AbstractIntRangeWidget):
    valueChanged = QtCore.Signal(tuple)

    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.start_spinbox = QtGui.QSpinBox()
        self.end_spinbox = QtGui.QSpinBox()
        self.slider = QSpanSlider(QtCore.Qt.Horizontal)

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractIntRangeWidget.__init__(self)

        # To be compatible with tree or table views, slider must keep focus
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumHeight(22)
        self.start_spinbox.setMinimumHeight(18)
        self.end_spinbox.setMinimumHeight(18)
        self.slider.setMinimumHeight(18)

        self.slider.lowerPositionChanged.connect(self.start_spinbox.setValue)
        self.slider.lowerPositionChanged.connect(self.end_spinbox.setMinimum)
        self.slider.upperPositionChanged.connect(self.end_spinbox.setValue)
        self.slider.upperPositionChanged.connect(self.start_spinbox.setMaximum)

        self.start_spinbox.valueChanged.connect(self.slider.setLowerValue)
        self.end_spinbox.valueChanged.connect(self.slider.setUpperValue)

        self.start_spinbox.valueChanged.connect(self.end_spinbox.setMinimum)
        self.end_spinbox.valueChanged.connect(self.start_spinbox.setMaximum)
        self.start_spinbox.valueChanged.connect(self.notify_start_value_changed)
        self.end_spinbox.valueChanged.connect(self.notify_end_value_changed)

        self.slider.spanChanged.connect(self.notify_value_changed)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.start_spinbox)
        layout.addWidget(self.slider)
        layout.addWidget(self.end_spinbox)

        self.value_changed_signal = self.valueChanged

    def reset(self, value=(0, 255), minimum=None, maximum=None, **kwargs):
        if minimum is not None:
            self.slider.setMinimum(minimum)
            self.start_spinbox.setMinimum(minimum)
        if maximum is not None:
            self.slider.setMaximum(maximum)
            self.end_spinbox.setMaximum(maximum)
        self.start_spinbox.setMaximum(value[1])
        self.end_spinbox.setMinimum(value[0])

        self.setValue(value)

    def apply(self, control):
        AbstractQtControlWidget.apply(self, control)
        control.interface.min = self.slider.minimum()
        control.interface.max = self.slider.maximum()
        control.value = self.value()

    def value(self, interface=None):
        return (self.slider.lowerValue(), self.slider.upperValue())

    def setValue(self, value):
        self.slider.setSpan(value[0], value[1])
        self.start_spinbox.setValue(value[0])
        self.start_spinbox.setMaximum(value[1])
        self.end_spinbox.setValue(value[1])
        self.end_spinbox.setMinimum(value[0])

    def notify_value_changed(self, lower_value, upper_value):
        self.valueChanged.emit((lower_value, upper_value))

    def notify_start_value_changed(self, value):
        self.valueChanged.emit((value, self.end_spinbox.value()))

    def notify_end_value_changed(self, value):
        self.valueChanged.emit((self.start_spinbox.value(), value))
Exemplo n.º 6
0
 def __init__(self):
     QSpanSlider.__init__(self)
     AbstractIntRangeWidget.__init__(self)
     self.spanChanged.connect(self.notify_value_changed)
     self.value_changed_signal = self.valueChanged