コード例 #1
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.span_slider = QxtSpanSlider()
        self.sbox_lower = QSpinBox()
        self.sbox_upper = QSpinBox()
        self.horizontal_layout = QHBoxLayout()
        self.horizontal_layout.setContentsMargins(5, 5, 5, 5)
        self.horizontal_layout.addWidget(self.sbox_lower)
        self.horizontal_layout.addWidget(self.span_slider)
        self.horizontal_layout.addWidget(self.sbox_upper)

        # Signal and slots
        self.sbox_lower.valueChanged.connect(
            self.slot_sbox_lower_value_changed)
        self.sbox_upper.valueChanged.connect(
            self.slot_sbox_upper_value_changed)
        self.span_slider.lowerPositionChanged.connect(
            self.slot_span_slider_lower_position_changed)
        self.span_slider.upperPositionChanged.connect(
            self.slot_span_slider_upper_position_changed)

        self.setLayout(self.horizontal_layout)
コード例 #2
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.span_slider = QxtSpanSlider()
        self.sbox_lower = QSpinBox()
        self.sbox_upper = QSpinBox()
        self.horizontal_layout = QHBoxLayout()
        self.horizontal_layout.setContentsMargins(5, 5, 5, 5)
        self.horizontal_layout.addWidget(self.sbox_lower)
        self.horizontal_layout.addWidget(self.span_slider)
        self.horizontal_layout.addWidget(self.sbox_upper)

        # Signal and slots
        self.sbox_lower.valueChanged.connect(self.slot_sbox_lower_value_changed)
        self.sbox_upper.valueChanged.connect(self.slot_sbox_upper_value_changed)
        self.span_slider.lowerPositionChanged.connect(self.slot_span_slider_lower_position_changed)
        self.span_slider.upperPositionChanged.connect(self.slot_span_slider_upper_position_changed)

        self.setLayout(self.horizontal_layout)
コード例 #3
0
class widgetSpinBoxSpanSlider(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.span_slider = QxtSpanSlider()
        self.sbox_lower = QSpinBox()
        self.sbox_upper = QSpinBox()
        self.horizontal_layout = QHBoxLayout()
        self.horizontal_layout.setContentsMargins(5, 5, 5, 5)
        self.horizontal_layout.addWidget(self.sbox_lower)
        self.horizontal_layout.addWidget(self.span_slider)
        self.horizontal_layout.addWidget(self.sbox_upper)

        # Signal and slots
        self.sbox_lower.valueChanged.connect(self.slot_sbox_lower_value_changed)
        self.sbox_upper.valueChanged.connect(self.slot_sbox_upper_value_changed)
        self.span_slider.lowerPositionChanged.connect(self.slot_span_slider_lower_position_changed)
        self.span_slider.upperPositionChanged.connect(self.slot_span_slider_upper_position_changed)

        self.setLayout(self.horizontal_layout)

    def slot_sbox_lower_value_changed(self, value):
        value_sbox_upper = self.sbox_upper.value()
        value_sbox_lower = value

        if value_sbox_upper < value_sbox_lower:
            self.span_slider.swapControls()
            self.span_slider.setUpperValue(value_sbox_lower)
            self.span_slider.setUpperPosition(value_sbox_lower)
            self.span_slider.setLowerValue(value_sbox_upper)
            self.span_slider.setLowerPosition(value_sbox_upper)
            self.sbox_upper.setValue(value_sbox_lower)
            self.sbox_lower.setValue(value_sbox_upper)
            return

        self.span_slider.setLowerValue(value_sbox_lower)
        self.span_slider.setLowerPosition(value_sbox_lower)

    def slot_sbox_upper_value_changed(self, value):
        value_sbox_upper = value
        value_sbox_lower = self.sbox_lower.value()

        if value_sbox_upper < value_sbox_lower:
            self.span_slider.swapControls()
            self.span_slider.setUpperValue(value_sbox_lower)
            self.span_slider.setUpperPosition(value_sbox_lower)
            self.span_slider.setLowerValue(value_sbox_upper)
            self.span_slider.setLowerPosition(value_sbox_upper)
            self.sbox_upper.setValue(value_sbox_lower)
            self.sbox_lower.setValue(value_sbox_upper)
            return

        self.span_slider.setUpperValue(value_sbox_upper)
        self.span_slider.setUpperPosition(value_sbox_upper)

    def slot_span_slider_lower_position_changed(self, value):
        self.sbox_lower.setValue(value)

    def slot_span_slider_upper_position_changed(self, value):
        self.sbox_upper.setValue(value)
コード例 #4
0
class widgetSpinBoxSpanSlider(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.span_slider = QxtSpanSlider()
        self.sbox_lower = QSpinBox()
        self.sbox_upper = QSpinBox()
        self.horizontal_layout = QHBoxLayout()
        self.horizontal_layout.setContentsMargins(5, 5, 5, 5)
        self.horizontal_layout.addWidget(self.sbox_lower)
        self.horizontal_layout.addWidget(self.span_slider)
        self.horizontal_layout.addWidget(self.sbox_upper)

        # Signal and slots
        self.sbox_lower.valueChanged.connect(
            self.slot_sbox_lower_value_changed)
        self.sbox_upper.valueChanged.connect(
            self.slot_sbox_upper_value_changed)
        self.span_slider.lowerPositionChanged.connect(
            self.slot_span_slider_lower_position_changed)
        self.span_slider.upperPositionChanged.connect(
            self.slot_span_slider_upper_position_changed)

        self.setLayout(self.horizontal_layout)

    def slot_sbox_lower_value_changed(self, value):
        value_sbox_upper = self.sbox_upper.value()
        value_sbox_lower = value

        if value_sbox_upper < value_sbox_lower:
            self.span_slider.swapControls()
            self.span_slider.setUpperValue(value_sbox_lower)
            self.span_slider.setUpperPosition(value_sbox_lower)
            self.span_slider.setLowerValue(value_sbox_upper)
            self.span_slider.setLowerPosition(value_sbox_upper)
            self.sbox_upper.setValue(value_sbox_lower)
            self.sbox_lower.setValue(value_sbox_upper)
            return

        self.span_slider.setLowerValue(value_sbox_lower)
        self.span_slider.setLowerPosition(value_sbox_lower)

    def slot_sbox_upper_value_changed(self, value):
        value_sbox_upper = value
        value_sbox_lower = self.sbox_lower.value()

        if value_sbox_upper < value_sbox_lower:
            self.span_slider.swapControls()
            self.span_slider.setUpperValue(value_sbox_lower)
            self.span_slider.setUpperPosition(value_sbox_lower)
            self.span_slider.setLowerValue(value_sbox_upper)
            self.span_slider.setLowerPosition(value_sbox_upper)
            self.sbox_upper.setValue(value_sbox_lower)
            self.sbox_lower.setValue(value_sbox_upper)
            return

        self.span_slider.setUpperValue(value_sbox_upper)
        self.span_slider.setUpperPosition(value_sbox_upper)

    def slot_span_slider_lower_position_changed(self, value):
        self.sbox_lower.setValue(value)

    def slot_span_slider_upper_position_changed(self, value):
        self.sbox_upper.setValue(value)