Skip to content

Commit

Permalink
Replace all instances of UISliderLEditWidget with UISliderEditWidget,
Browse files Browse the repository at this point in the history
update docstrings
  • Loading branch information
jcornall committed Jan 3, 2025
1 parent 0545d59 commit 9e6f42b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
6 changes: 3 additions & 3 deletions eqt/ui/UIFormWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PySide2 import QtWidgets

from .UISliderLEditWidget import UISliderLEditWidget
from .UISliderEditWidget import UISliderEditWidget
from .UISliderWidget import UISliderWidget


Expand Down Expand Up @@ -336,7 +336,7 @@ 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):
elif isinstance(widget, UISliderEditWidget) 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()
Expand Down Expand Up @@ -424,7 +424,7 @@ 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)):
elif isinstance(widget, (UISliderEditWidget, QtWidgets.QWidget)):
widget.setValue(value)
# isinstance(QWidget) must be last due to other QtWidgets inheriting from it

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from PySide2.QtWidgets import QGridLayout, QLabel, QLineEdit, QSlider, QWidget


class UISliderLEditWidget(QWidget):
'''Creates a QGridLayout that includes a QSlider, min/max QLabels and a QLineEdit.
class UISliderEditWidget(QWidget):
'''Creates a QGridLayout that includes a QSlider, min/median/max QLabels and a QLineEdit.
The QLineEdit is updated with the value of the slider and vice versa.
Parameters
Expand All @@ -12,6 +12,7 @@ class UISliderLEditWidget(QWidget):
max : float
step_size : float
scale_factor : float
tick_interval : float
'''
def __init__(self, minimum=0.0, maximum=10.0, step_size=1.0, scale_factor=1.0,
tick_interval=1.0):
Expand Down
1 change: 1 addition & 0 deletions eqt/ui/UISliderWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class UISliderWidget(QSlider):
maximum : float
step_size : float
scale_factor : float
tick_interval : float
'''
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):
Expand Down
6 changes: 3 additions & 3 deletions examples/dialog_example_uislider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PySide2 import QtWidgets

from eqt.ui import FormDialog, UISliderLEditWidget, UISliderWidget
from eqt.ui import FormDialog, UISliderEditWidget, UISliderWidget


class MainUI(QtWidgets.QMainWindow):
Expand Down Expand Up @@ -39,8 +39,8 @@ def openFormDialog(self):
dialog.addWidget(line_edit, '', 'input_line_edit1')

# add input 2 as UISliderLineEditWidget
uislider = UISliderLEditWidget.UISliderLEditWidget(minimum=0.0, maximum=100.0,
scale_factor=10.0)
uislider = UISliderEditWidget.UISliderEditWidget(minimum=0.0, maximum=100.0,
scale_factor=10.0)

# add to the form widget
dialog.addWidget(uislider, 'UISlider 2:', 'input_slider2')
Expand Down
6 changes: 3 additions & 3 deletions examples/dialog_save_state_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PySide2 import QtWidgets

from eqt.ui import FormDialog
from eqt.ui.UISliderLEditWidget import UISliderLEditWidget
from eqt.ui.UISliderEditWidget import UISliderEditWidget
from eqt.ui.UISliderWidget import UISliderWidget


Expand Down Expand Up @@ -45,8 +45,8 @@ def __init__(self, parent=None):
dialog.addWidget(max_label, '', 'input_max_label1')
dialog.addWidget(line_edit, '', 'input_line_edit1')

dialog.addWidget(UISliderLEditWidget(minimum=0.0, maximum=100.0, scale_factor=10.0),
'UISliderLEditWidget:', 'uiSliderLEditWidget')
dialog.addWidget(UISliderEditWidget(minimum=0.0, maximum=100.0, scale_factor=10.0),
'UISliderEditWidget:', 'uiSliderEditWidget')

dialog.addWidget(QtWidgets.QRadioButton('test 1'), 'RadioButton 1: ', 'radioButton1')
dialog.addWidget(QtWidgets.QRadioButton('test 2'), 'RadioButton 2: ', 'radioButton2')
Expand Down
8 changes: 4 additions & 4 deletions examples/utilitiesForExamples.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PySide2 import QtWidgets

from eqt.ui.UISliderLEditWidget import UISliderLEditWidget
from eqt.ui.UISliderEditWidget import UISliderEditWidget
from eqt.ui.UISliderWidget import UISliderWidget


Expand All @@ -10,7 +10,7 @@ def list_all_widgets():
'comboBox': QtWidgets.QComboBox(), 'doubleSpinBox': QtWidgets.QDoubleSpinBox(),
'spinBox': QtWidgets.QSpinBox(), 'slider': QtWidgets.QSlider(),
'uiSliderWidget': UISliderWidget(QtWidgets.QLineEdit(), QtWidgets.QLabel()),
'uiSliderLEditWidget': UISliderLEditWidget(),
'uiSliderEditWidget': UISliderEditWidget(),
'radioButton': QtWidgets.QRadioButton('test radio button'),
'textEdit': QtWidgets.QTextEdit('test text edit'),
'plainTextEdit': QtWidgets.QPlainTextEdit('test plain text edit'),
Expand Down Expand Up @@ -44,8 +44,8 @@ def addWidgetsToExample(form):
form.addWidget(max_label, '', 'uiSliderMaxLabel')
form.addWidget(line_edit, '', 'uiSliderLineEdit')

form.addWidget(UISliderLEditWidget(minimum=0.0, maximum=100.0, scale_factor=10.0),
'UISliderLEditWidget:', 'uiSliderLEditWidget')
form.addWidget(UISliderEditWidget(minimum=0.0, maximum=100.0, scale_factor=10.0),
'UISliderEditWidget:', 'uiSliderEditWidget')

form.addWidget(QtWidgets.QRadioButton('select me'), 'RadioButton: ', 'radioButton')
form.addWidget(QtWidgets.QTextEdit('write text here'), 'TextEdit: ', 'textEdit')
Expand Down
9 changes: 9 additions & 0 deletions test/test_UISliderEditWidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import unittest


class UISliderEditWidget(unittest.TestCase):
def setUp(self):
return super().setUp()

def tearDown(self):
return super().tearDown()
28 changes: 14 additions & 14 deletions test/test__formUI_status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from eqt.ui.FormDialog import AdvancedFormDialog, FormDialog
from eqt.ui.UIFormWidget import FormDockWidget, FormWidget
from eqt.ui.UISliderLEditWidget import UISliderLEditWidget
from eqt.ui.UISliderEditWidget import UISliderEditWidget
from eqt.ui.UISliderWidget import UISliderWidget

from . import is_ci, skip
Expand All @@ -34,13 +34,13 @@ def exampleState(self):
state = [{
'label_value': 'Test label state 0', 'checkBox_value': False, 'comboBox_value': 0,
'doubleSpinBox_value': 10.0, 'spinBox_value': 10, 'slider_value': 10,
'uiSliderWidget_value': 10, 'uiSliderLEditWidget_value': 10.0,
'uiSliderWidget_value': 10, 'uiSliderEditWidget_value': 10.0,
'radioButton_value': False, 'textEdit_value': 'test edit 0',
'plainTextEdit_value': 'test plain 0', 'lineEdit_value': 'test line 0',
'button_value': False}, {
'label_value': 'Test label state 1', 'checkBox_value': True, 'comboBox_value': 1,
'doubleSpinBox_value': 1.0, 'spinBox_value': 1, 'slider_value': 1,
'uiSliderWidget_value': 1, 'uiSliderLEditWidget_value': 1.0,
'uiSliderWidget_value': 1, 'uiSliderEditWidget_value': 1.0,
'radioButton_value': True, 'textEdit_value': 'test edit 1',
'plainTextEdit_value': 'test plain 1', 'lineEdit_value': 'test line 1',
'button_value': True}]
Expand All @@ -57,7 +57,7 @@ def list_all_widgets(self):
'doubleSpinBox': QtWidgets.QDoubleSpinBox(), 'spinBox': QtWidgets.QSpinBox(),
'slider': QtWidgets.QSlider(), 'uiSliderWidget': UISliderWidget(
QtWidgets.QLineEdit(),
QtWidgets.QLabel()), 'uiSliderLEditWidget': UISliderLEditWidget(),
QtWidgets.QLabel()), 'uiSliderEditWidget': UISliderEditWidget(),
'radioButton': QtWidgets.QRadioButton('test radio button'),
'textEdit': QtWidgets.QTextEdit('test text edit'),
'plainTextEdit': QtWidgets.QPlainTextEdit('test plain text edit'),
Expand Down Expand Up @@ -111,8 +111,8 @@ def set_state(self, i: int):
self.form.getWidget('slider').setValue(state[i]['slider_value'])
# UISlider
self.form.getWidget('uiSliderWidget').setValue(state[i]['uiSliderWidget_value'])
# UISliderLEditWidget
self.form.getWidget('uiSliderLEditWidget').setValue(state[i]['uiSliderLEditWidget_value'])
# UISliderEditWidget
self.form.getWidget('uiSliderEditWidget').setValue(state[i]['uiSliderEditWidget_value'])
# QRadioButton
self.form.getWidget('radioButton').setChecked(state[i]['radioButton_value'])
# QTextEdit
Expand Down Expand Up @@ -148,9 +148,9 @@ def set_spanning_state(self, i: int):
self.form.getWidget('slider_spanning').setValue(state[i]['slider_value'])
# UISlider
self.form.getWidget('uiSliderWidget_spanning').setValue(state[i]['uiSliderWidget_value'])
# UISliderLEditWidget
self.form.getWidget('uiSliderLEditWidget_spanning').setValue(
state[i]['uiSliderLEditWidget_value'])
# UISliderEditWidget
self.form.getWidget('uiSliderEditWidget_spanning').setValue(
state[i]['uiSliderEditWidget_value'])
# QRadioButton
self.form.getWidget('radioButton_spanning').setChecked(state[i]['radioButton_value'])
# QTextEdit
Expand Down Expand Up @@ -384,18 +384,18 @@ def test_getWidgetState_returns_UISliderWidget_value(self):
self.assertEqual(
self.form.getWidgetState('uiSliderWidget_field')['value'], final_slider_value)

def test_getWidgetState_returns_UISliderLEditWidget_value(self):
"""Check that the value of the UISliderLEditWidget is returned in the state"""
def test_getWidgetState_returns_UISliderEditWidget_value(self):
"""Check that the value of the UISliderEditWidget is returned in the state"""
initial_slider_value = 0

self.assertEqual(
self.form.getWidgetState('uiSliderLEditWidget_field')['value'], initial_slider_value)
self.form.getWidgetState('uiSliderEditWidget_field')['value'], initial_slider_value)

final_slider_value = 1
self.form.getWidget('uiSliderLEditWidget').setValue(final_slider_value)
self.form.getWidget('uiSliderEditWidget').setValue(final_slider_value)

self.assertEqual(
self.form.getWidgetState('uiSliderLEditWidget_field')['value'], final_slider_value)
self.form.getWidgetState('uiSliderEditWidget_field')['value'], final_slider_value)

def test_getWidgetState_returns_QLineEdit_value(self):
"""Check that the value of the QLineEdit is saved to the state"""
Expand Down

0 comments on commit 9e6f42b

Please sign in to comment.