Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QLineEdit support to UISliderWidget #168

Merged
merged 70 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3423fb0
Rewrite UISliderWidget class to take a QDoubleSpinBox as input
jcornall Dec 16, 2024
5c8dca9
Revert changes to dialog_example_3_save_default.py
jcornall Dec 16, 2024
fe05eae
Add dialog_example_uislider.py
jcornall Dec 16, 2024
ca10630
Update CHANGELOG.md
jcornall Dec 16, 2024
2de3c5b
Add minimum and maximum value parameters and logic to UISliderWidget.py
jcornall Dec 18, 2024
c3f39dc
Update CHANGELOG.md
jcornall Dec 18, 2024
68e58ea
Add UISliderLineEditWidget class, update comments
jcornall Dec 18, 2024
d86f1f7
Replace QDoubleSpinBox in UISliderWidget class with QLineEdit
jcornall Dec 19, 2024
d255d49
Replace QDoubleSpinBox in UISliderLEditWidget class with QLineEdit
jcornall Dec 19, 2024
9916abe
Merge branch 'main' into uislider-dspinbox
jcornall Dec 20, 2024
e93a971
Update CHANGELOG.md
jcornall Dec 20, 2024
a375e9b
Add QLabel to UISliderWidget to display max slider value
jcornall Dec 20, 2024
1313217
Add tick_interval attribute to UISliderWidget class
jcornall Dec 23, 2024
f7517ab
Reformat method names to use camel case, add value getters/setters
jcornall Jan 2, 2025
5c595bf
Add UISliderLEditWidget case to getWidgetState() and applyWidgetState()
jcornall Jan 2, 2025
1545425
Update examples and tests to include UISliderLEditWidget
jcornall Jan 3, 2025
0545d59
Update tests and change defaults for UISlider classes
jcornall Jan 3, 2025
9e6f42b
Replace all instances of UISliderLEditWidget with UISliderEditWidget,
jcornall Jan 3, 2025
c4c9faf
Update CHANGELOG.md
jcornall Jan 3, 2025
a767b0d
Add float support to UISliderWidget value getter and setter
jcornall Jan 3, 2025
8136350
Connect QApplication focusChanged signal to UISlider QLineEdits
jcornall Jan 6, 2025
80e3f6a
Add additional UISliderEditWidget tests
jcornall Jan 7, 2025
9add01a
Merge branch 'main' into uislider-dspinbox
jcornall Jan 8, 2025
d76d8a3
Replace Pyside2 imports with pyqt
jcornall Jan 8, 2025
0d7be4f
Update UISliderWidget, remove UISliderEditWidget, implement scaling
jcornall Jan 9, 2025
c0fa449
Add minimum/maximum argument check to __init__()
jcornall Jan 9, 2025
9f347ac
Correct UISliderWidget minimum/maximum values
jcornall Jan 9, 2025
3114d02
Correct formatting of docstrings
jcornall Jan 10, 2025
162d9a0
Add UISlider tests
jcornall Jan 17, 2025
da49b61
Add checks for non-default UISlider inputs
jcornall Jan 17, 2025
72c14db
Replace references to Pyside2 with qtpy
jcornall Jan 17, 2025
a88d5df
Add parameterized to list of optional dependencies
jcornall Jan 17, 2025
8c6de56
Remove setUp()
jcornall Jan 17, 2025
706db47
Remove parameterized from optional dependencies, add skip_ci decorator
jcornall Jan 17, 2025
150fdbf
Add parameterized to optional dependencies
jcornall Jan 17, 2025
a975d7f
Add returnPressed signal to UISliderWidget
jcornall Jan 17, 2025
112eecf
Fix error when QLineEdit return an empty string
jcornall Jan 17, 2025
e0141c1
Modify UISliderWidget default number_of_ticks, add _updateSlider() call
jcornall Jan 17, 2025
737f93c
Correct recursive method call in setValue()
jcornall Jan 17, 2025
df480fc
Modify UISliderWidget default number_of_ticks
jcornall Jan 17, 2025
b25d151
Correct expected value in parameterized unit test
jcornall Jan 20, 2025
c3431fd
Add additional docstrings to UISliderWidget methods and tests
jcornall Jan 21, 2025
b062bab
Add additional parameterized test cases
jcornall Jan 22, 2025
edd28e0
Update docstrings
jcornall Jan 22, 2025
f7b5d05
Update UISliderWidget docstrings, methods and tests
jcornall Jan 23, 2025
8bf7f3e
Add additional UISliderWidget methods, update tests, docstrings and
jcornall Jan 27, 2025
1775e94
Add UISlider to insert_widgets_examply.py, fix onCancel() behaviour
jcornall Jan 27, 2025
e9e4eab
Update docstrings
jcornall Jan 28, 2025
88014e9
Add UISliderWidget to remove_widgets_example.py, update docstrings
jcornall Jan 29, 2025
1432a80
Modify setValue() to also update the value of the UISlider's QSlider
jcornall Jan 29, 2025
bdee17a
Remove skip_ci decorator from TestUISliderWidget, update recipe
jcornall Jan 29, 2025
4053cde
Modify tearDown() to quit the current QApplication instance after each
jcornall Jan 29, 2025
546aa1b
Patch QApplication in TestUISliderWidget tests
jcornall Jan 29, 2025
fbd0c7c
Modify QApplication patch
jcornall Jan 29, 2025
94fdb7f
Isolate QApplication dependency within UISliderWidget by adding
jcornall Jan 29, 2025
4521810
Add pyqt to qtbindings
jcornall Jan 29, 2025
1c83b6e
Correct 'pyqt' to 'qtpy' in qtbindings
jcornall Jan 29, 2025
3b641d3
Remove qtpy from qtbindings
jcornall Jan 29, 2025
96cb86f
Test adding QApplication to setUp() and tearDown() methods
jcornall Jan 29, 2025
ae3fe75
Remove QApplication from setUp() and tearDown() methods
jcornall Jan 29, 2025
e1f7199
Test empty qtbindings
jcornall Jan 29, 2025
3a999a0
Test adding qtbindings
jcornall Jan 29, 2025
43c2f31
Move pip install of qtbindings
jcornall Jan 29, 2025
604bc08
Reset changes to test.yml
jcornall Jan 29, 2025
edc832a
Add @skip_ci decorator to TestUISliderWidget class
jcornall Jan 30, 2025
a0a074d
Test bare minimum UISlider object instantiation with GitHub Actions
jcornall Jan 30, 2025
3497399
Update testing information in CONTRIBUTING.md
jcornall Jan 30, 2025
d535b10
Update CHANGELOG.md
jcornall Jan 30, 2025
30a8fb0
Add @skip_ci decorator to TestUISliderWidget class
jcornall Jan 30, 2025
11f0ae5
Update CHANGELOG.md, remove redundant test, correct docstring
jcornall Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Update `CONTRIBUTING.md` with detailed installation and contribution instructions (#161)
- Limit Python version to <3.12 in conda recipe (#161)
- Change SessionDirectorySelectionDialog `.open()` call to `.exec()` (#163, #165)
- Add `QDoubleSpinBox` support to `UISliderWidget` (#168)
jcornall marked this conversation as resolved.
Show resolved Hide resolved

# Version 1.0.1
- Add NoBorderScrollArea, example and tests (#155)
Expand Down
28 changes: 21 additions & 7 deletions eqt/ui/UISliderWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ class UISliderWidget(QSlider):
'''Creates a Slider widget which updates
a QLabel with its value (which may be scaled
to a non-integer value by setting the scale_factor)'''
def __init__(self, label, scale_factor=1):
def __init__(self, dspinbox, min=0.00, max=1.00, scale_factor=1, parent=None):
QSlider.__init__(self)
self.label = label
self.parent = parent
jcornall marked this conversation as resolved.
Show resolved Hide resolved
self.scale_factor = scale_factor

self.setOrientation(QtCore.Qt.Horizontal)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.setTickPosition(QSlider.TicksBelow)
self.valueChanged.connect(self.show_slider_value)

self.sliderPressed.connect(self.update_dspinbox)
self.sliderMoved.connect(self.update_dspinbox)
self.sliderReleased.connect(self.update_dspinbox)

self.dspinbox = dspinbox
self.dspinbox.editingFinished.connect(self.update_slider)

def get_slider_value(self):
return self.value() * self.scale_factor
return self.value()

def get_dspinbox_value(self):
return self.dspinbox.value()

def update_slider(self):
dspinbox_value = int(self.get_dspinbox_value())
self.setValue(dspinbox_value)

def show_slider_value(self):
value = self.get_slider_value()
self.label.setText(str(value))
def update_dspinbox(self):
slider_value = float(self.get_slider_value())
self.dspinbox.setValue(slider_value)
58 changes: 58 additions & 0 deletions examples/dialog_example_uislider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import sys

from PySide2 import QtWidgets

from eqt.ui import FormDialog, UISliderWidget


class MainUI(QtWidgets.QMainWindow):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)

pb = QtWidgets.QPushButton(self)
pb.setText("Open Dialog with form layout")
pb.clicked.connect(lambda: self.openFormDialog())

layout = QtWidgets.QHBoxLayout()
layout.addWidget(pb)
widg = QtWidgets.QWidget()
widg.setLayout(layout)

self.setCentralWidget(widg)

self.show()

def openFormDialog(self):
dialog = FormDialog(parent=self, title='Example')
jcornall marked this conversation as resolved.
Show resolved Hide resolved
dialog.Ok.clicked.connect(lambda: self.accepted())

# Example on how to add elements to the FormDialog
# add input 1 as UISliderWidget and DoubleSpinBox
dspinbox = QtWidgets.QDoubleSpinBox()
uislider = UISliderWidget.UISliderWidget(dspinbox)

# finally add to the form widget
dialog.addWidget(uislider, 'Slider 1', 'input_slider')
dialog.addWidget(dspinbox, '', 'input_dspinbox')

# store a reference
self.dialog = dialog
self.dialog.onCancel = self.rejected
dialog.exec()

def accepted(self):
print("accepted")
jcornall marked this conversation as resolved.
Show resolved Hide resolved
print(self.dialog.widgets['input_slider_field'].value())
print(self.dialog.widgets['input_dspinbox_field'].value())
self.dialog.close()
jcornall marked this conversation as resolved.
Show resolved Hide resolved

def rejected(self):
print("rejected")
jcornall marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)

window = MainUI()

sys.exit(app.exec_())
Loading