diff --git a/eqt/ui/UIFormWidget.py b/eqt/ui/UIFormWidget.py index 2fdcd98..e8b1cb3 100644 --- a/eqt/ui/UIFormWidget.py +++ b/eqt/ui/UIFormWidget.py @@ -326,9 +326,7 @@ def getWidgetState(self, widget, role=None): widget_state['value'] = widget.isChecked() elif isinstance(widget, QtWidgets.QComboBox): widget_state['value'] = widget.currentIndex() - elif isinstance(widget, UISliderWidget) or isinstance(widget, UISliderLEditWidget): - widget_state['value'] = widget.getValue() - elif isinstance(widget, QtWidgets.QSlider): + elif isinstance(widget, UISliderWidget) or isinstance(widget, QtWidgets.QSlider): widget_state['value'] = widget.value() elif isinstance(widget, (QtWidgets.QDoubleSpinBox, QtWidgets.QSpinBox)): widget_state['value'] = widget.value() @@ -338,6 +336,9 @@ def getWidgetState(self, widget, role=None): widget_state['value'] = widget.isChecked() elif isinstance(widget, (QtWidgets.QTextEdit, QtWidgets.QPlainTextEdit)): widget_state['value'] = widget.toPlainText() + elif isinstance(widget, UISliderLEditWidget) or isinstance(widget, QtWidgets.QWidget): + widget_state['value'] = widget.getValue() + # isinstance(QWidget) must be last due to other QtWidgets inheriting from it widget_state['enabled'] = widget.isEnabled() widget_state['visible'] = widget.isVisible() widget_state['widget_row'] = self.getWidgetRow(name, role) @@ -411,7 +412,7 @@ def applyWidgetState(self, name, state, role=None): widget.setChecked(value) elif isinstance(widget, QtWidgets.QComboBox): widget.setCurrentIndex(value) - elif isinstance(widget, (UISliderWidget, UISliderLEditWidget, QtWidgets.QSlider)): + elif isinstance(widget, (UISliderWidget, QtWidgets.QSlider)): widget.setValue(value) elif isinstance(widget, (QtWidgets.QDoubleSpinBox, QtWidgets.QSpinBox)): widget.setValue(value) @@ -423,6 +424,9 @@ def applyWidgetState(self, name, state, role=None): widget.setChecked(value) elif isinstance(widget, (QtWidgets.QTextEdit, QtWidgets.QPlainTextEdit)): widget.setPlainText(value) + elif isinstance(widget, (UISliderLEditWidget, QtWidgets.QWidget)): + widget.setValue(value) + # isinstance(QWidget) must be last due to other QtWidgets inheriting from it def applyWidgetStates(self, states): ''' diff --git a/eqt/ui/UISliderLEditWidget.py b/eqt/ui/UISliderLEditWidget.py index 6ed6fb2..d5268c9 100644 --- a/eqt/ui/UISliderLEditWidget.py +++ b/eqt/ui/UISliderLEditWidget.py @@ -13,7 +13,7 @@ class UISliderLEditWidget(QWidget): step_size : float scale_factor : float ''' - def __init__(self, minimum=0.0, maximum=1.0, step_size=1.0, scale_factor=1.0, + def __init__(self, minimum=0.0, maximum=10.0, step_size=1.0, scale_factor=1.0, tick_interval=1.0): QWidget.__init__(self) diff --git a/eqt/ui/UISliderWidget.py b/eqt/ui/UISliderWidget.py index d9197dd..d876a44 100644 --- a/eqt/ui/UISliderWidget.py +++ b/eqt/ui/UISliderWidget.py @@ -18,7 +18,7 @@ class UISliderWidget(QSlider): step_size : float scale_factor : float ''' - def __init__(self, line_edit, max_label, minimum=0.0, maximum=1.0, scale_factor=1.0, + def __init__(self, line_edit, max_label, minimum=0.0, maximum=10.0, scale_factor=1.0, step_size=1.0, tick_interval=1.0): QSlider.__init__(self) @@ -63,9 +63,6 @@ def __init__(self, line_edit, max_label, minimum=0.0, maximum=1.0, scale_factor= self.max_label.setAlignment(QtCore.Qt.AlignRight) self.max_label.setText(str(self.maximum)) - def getValue(self): - return self.getLineEditValue() - def getSliderValue(self): return self.value() diff --git a/test/test__formUI_status_test.py b/test/test__formUI_status_test.py index 5d059df..577e4cf 100644 --- a/test/test__formUI_status_test.py +++ b/test/test__formUI_status_test.py @@ -392,7 +392,7 @@ def test_getWidgetState_returns_UISliderLEditWidget_value(self): self.form.getWidgetState('uiSliderLEditWidget_field')['value'], initial_slider_value) final_slider_value = 1 - self.form.getWidget('UISliderLEditWidget').setValue(final_slider_value) + self.form.getWidget('uiSliderLEditWidget').setValue(final_slider_value) self.assertEqual( self.form.getWidgetState('uiSliderLEditWidget_field')['value'], final_slider_value)