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

Open
wants to merge 70 commits into
base: main
Choose a base branch
from
Open

Conversation

jcornall
Copy link
Collaborator

@jcornall jcornall commented Dec 16, 2024

Closes #125 #60 #178

The current UISliderWidget is limited due to the following factors:

  • Instantiating a UISliderWidget requires a QLabel, which is updated to show the value of the slider
  • The QLabel cannot be updated manually
  • The slider does not support float/double values

This pull request originally removed the QLabel parameter in favour of a QDoubleSpinBox parameter. It was decided that to provide the best user experience and enable flexibility to modify the widget in the future, more changes would be required:

  • The UISliderWidget class now inherits from the QWidget class, instead of QSlider
  • The class now creates a QGridLayout, which ensures future flexibility in modifying/customising the arrangement of the subwidgets within the UISliderWidget
  • Instead of a QDoubleSpinBox, a QLineEdit has been added so that users can fine-tune the widget's value
  • New QLabels have been added to display the minimum, median and maximum values of the widget
  • Validation (QValidator and conditional checks) has been added to ensure arguments and user inputs are valid, alongside behaviour to handle invalid inputs
  • Parameterized unit tests have been added, testing the UISliderWidget specifically, see test_UISliderWidget.py
  • Existing examples in the /examples/ folder have been updated to accommodate the updated UISliderWidget
  • Docstrings have been added to the UISliderWidget class, the tests, and the example
  • Calls to the UISliderWidget class have been updated elsewhere in eqt in line with the changes made

Note

By default the QSlider.value() method only returns integer values - even if the value of the QLineEdit is a float/double, this value is automatically converted to an integer when the QSlider value is updated. Additional methods have been implemented to convert the QSlider value into a scaled QLineEdit value, and vice versa. This means the QSlider can now accurately represent float/double values.

Current Tasks:

  • Implement QLineEdit
  • Remove hardcoded values
  • Make sure spinbox is linked to slider
  • Overload the init, one with the DSpinBox and one without
  • Add min and max QLabels
  • Consider whether to split the class into two separate classes
  • Add tests for the widget to eqt

@jcornall jcornall added this to the Version x.x.x milestone Dec 16, 2024
@jcornall jcornall requested a review from DanicaSTFC December 16, 2024 16:28
@jcornall jcornall self-assigned this Dec 16, 2024
eqt/ui/UISliderWidget.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@jcornall jcornall changed the title Add QDoubleSpinBox support to UISliderWidget Add QLineEdit support to UISliderWidget Dec 19, 2024
@jcornall
Copy link
Collaborator Author

Updated PR title to reflect changes to the design of the UISliderWidget class.

Following discussions with @paskino and @DanicaSTFC, it was agreed that instead of a QDoubleSpinBox the UISliderWidget class would make better use of a QLineEdit, removing restrictions on the decimal values users can input.

@jcornall
Copy link
Collaborator Author

image

QSlider 1: Modified UISliderWidget, individual widgets passed as arguments to connect them to the QSlider, then added to the FormDialog afterwards.
QSlider 2: New class UISliderLEditWidget, which creates its own widgets and adds them to a layout for display.

@jcornall
Copy link
Collaborator Author

jcornall commented Jan 29, 2025

Updated examples to include the UISliderWidget.

Insert Widgets Example:
image

Remove Widgets Example:
image

Also corrected the issue causing the KeyErrors in each example, see #178

@jcornall
Copy link
Collaborator Author

Following conversation with @lauramurgatroyd, decided the best course of action would be to re-add the @skip_ci decorator to the TestUISliderWidget class. The GitHub Actions aren't currently set up to handle running and testing GUI elements, hence why all the existing GUI tests are skipped - the only test file that runs tests I/O.

To set up the GitHub Actions to run the GUI tests would require substantial work, perhaps we can look into adding this functionality in a separate PR.

@jcornall jcornall requested a review from DanicaSTFC January 30, 2025 14:11
CHANGELOG.md Outdated Show resolved Hide resolved
eqt/ui/UISliderWidget.py Show resolved Hide resolved
test/test_UISliderWidget.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UISliderWidget to have a QDoubleSpinBox attached
3 participants