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 methods to UIFormWidget for saving and restoring widget states #64

Merged
merged 29 commits into from
Jan 19, 2023

Conversation

lauramurgatroyd
Copy link
Member

@lauramurgatroyd lauramurgatroyd commented Jan 17, 2023

Closes #61

  • Adds the following new methods to UIFormWidget, FormWidget, FormDialog and FormDockWidget:

    • saveAllWidgetStates - Saves the state of all widgets in the form. This can be used to restore the state of the widgets using the restoreAllSavedWidgetStates method.

    • restoreAllSavedWidgetStates - Restores the state of all widgets in the form to the state saved by the saveAllWidgetStates method. If the saveAllWidgetStates method has not been called, this method will do nothing.

    • getAllWidgetStates - Returns a dictionary of the state of all widgets in the form.

    • getWidgetState - Returns the state of the widget.

    • applyWidgetState - Applies the given state to the widget with the given name.

    • applyWidgetStates - Applies the given state to the widgets in the form given by the keys of the state dictionary.

  • Adds an example of a FormDialog: dialog_save_state_example.py where all of the widgets are saved and restored if you press "Ok", whereas the previous values of the dialog are restored if you press "Cancel".

  • Adds unit tests to fully cover all of the new methods

  • setup.py:

@lauramurgatroyd lauramurgatroyd changed the title Save widget states Add methods to UIFormWidget for saving and restoring widget states Jan 18, 2023
@lauramurgatroyd lauramurgatroyd marked this pull request as ready for review January 18, 2023 11:22
Copy link
Collaborator

@paskino paskino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some docstrings to be updated.

Why should we keep the default of role set to None?

I don't understand why the default widget name is name.

eqt/ui/FormDialog.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Show resolved Hide resolved
eqt/ui/UIFormWidget.py Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
eqt/ui/UIFormWidget.py Outdated Show resolved Hide resolved
lauramurgatroyd and others added 4 commits January 18, 2023 15:21
Co-authored-by: Edoardo Pasca <edo.paskino@gmail.com>
Co-authored-by: Edoardo Pasca <edo.paskino@gmail.com>
Co-authored-by: Edoardo Pasca <edo.paskino@gmail.com>
Co-authored-by: Edoardo Pasca <edo.paskino@gmail.com>
@lauramurgatroyd
Copy link
Member Author

I have updated the docstrings as you suggested

@lauramurgatroyd lauramurgatroyd merged commit 87f6fe7 into main Jan 19, 2023
@lauramurgatroyd lauramurgatroyd deleted the save_widget_states branch July 4, 2023 14:00
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.

Add methods to UIFormWidget for saving and reinstating values of widgets
2 participants