GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 0ffd1547 authored by Thomas Vincent's avatar Thomas Vincent

Allow to set label associated to slider

parent f9ea9b9d
......@@ -44,56 +44,66 @@ RangeSliderState = namedtuple('RangeSliderState', ['left', 'right',
class RoiAxisWidget(Qt.QWidget):
"""
Widget with a double slider and two line edit
displaying the slider range.
Widget with a double slider and two line edit displaying the slider range.
:param label: text displayed above the slider.
:param kwargs:
"""
sigSliderMoved = Qt.Signal(object)
""" Signal triggered when the slider values has changed."""
def slider(self):
"""
The RangeSlider instance of this widget.
:return:
"""
return self.__slider
"""Signal triggered when the slider values has changed."""
def __init__(self, label=None, **kwargs):
"""
:param label: text displayed above the slider.
:param kwargs:
"""
super(RoiAxisWidget, self).__init__(**kwargs)
layout = Qt.QGridLayout(self)
qLabel = FixedSizeLabel(nChar=1)
qLabel.setFrameStyle(Qt.QFrame.NoFrame | Qt.QFrame.Plain)
qLabel.setText(label)
self.__label = FixedSizeLabel(nChar=1)
self.__label.setFrameStyle(Qt.QFrame.NoFrame | Qt.QFrame.Plain)
self.__label.setText(label)
self.__slider = RangeSlider()
leftEdit = self.__leftEdit = StyledLineEdit(nChar=7)
leftEditValidator = Qt.QDoubleValidator(leftEdit)
self.__leftEdit = StyledLineEdit(nChar=7)
leftEditValidator = Qt.QDoubleValidator(self.__leftEdit)
leftEditValidator.setDecimals(6)
leftEdit.setValidator(leftEditValidator)
leftEdit.editingFinished.connect(self.__leftEditingFinished)
self.__leftEdit.setValidator(leftEditValidator)
self.__leftEdit.editingFinished.connect(self.__leftEditingFinished)
rightEdit = self.__rightEdit = StyledLineEdit(nChar=7)
rightEditValidator = Qt.QDoubleValidator(rightEdit)
self.__rightEdit = StyledLineEdit(nChar=7)
rightEditValidator = Qt.QDoubleValidator(self.__rightEdit)
rightEditValidator.setDecimals(6)
rightEdit.setValidator(rightEditValidator)
rightEdit.setValidator(Qt.QDoubleValidator(rightEdit))
rightEdit.editingFinished.connect(self.__rightEditingFinished)
self.__rightEdit.setValidator(rightEditValidator)
self.__rightEdit.editingFinished.connect(self.__rightEditingFinished)
layout.addWidget(qLabel, 0, 0)
layout.addWidget(self.__label, 0, 0)
layout.addWidget(self.__slider, 0, 1, 1, 2)
layout.addWidget(leftEdit, 1, 1)
layout.addWidget(rightEdit, 1, 2)
layout.addWidget(self.__leftEdit, 1, 1)
layout.addWidget(self.__rightEdit, 1, 2)
layout.setColumnStretch(3, 1)
self.__slider.sigValueChanged.connect(self.__sliderValueChanged)
def slider(self):
"""The RangeSlider instance of this widget.
:rtype: RangeSlider
"""
return self.__slider
def text(self):
"""Returns label text
:rtype: str
"""
return self.__label.text()
def setText(self, text):
"""Set the text of the label
:param str text:
"""
self.__label.setText(text)
def getSliderState(self):
"""Returns current slider state
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment