Skip to content

FormDialog widget_states KeyErrors in insert/remove widget examples #178

@jcornall

Description

@jcornall

The examples insert_widgets_example.py and remove_widgets_example.py both raise FormDialog KeyErrors when accessing the widget_states dictionary in specific situations:

insert_widgets_example.py:

  • After clicking the Open Form Dialog button and clicking Cancel, the following error message is displayed:
Traceback (most recent call last):
  File "C:\Users\pam62425\AppData\Local\mambaforge\envs\eqt_env\Lib\site-packages\eqt\ui\FormDialog.py", line 43, in _onCancel
    self.onCancel()
  File "c:\Users\pam62425\github\eqt\examples\insert_widgets_example.py", line 91, in onCancel
    ) != self.dialog.getWidgetStates()['Button insert vertical_field']['enabled'] is True:
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'Button insert vertical_field'
  • The message no longer displays after the user clicks OK and reopens the FormDialog - clicking Cancel no longer raises the KeyError

remove_widgets_example.py:

  • After clicking the Open Form Dialog button and Remove widget 1, clicking Cancel results in the following error message:
Traceback (most recent call last):
  File "C:\Users\pam62425\AppData\Local\mambaforge\envs\eqt_env\Lib\site-packages\eqt\ui\FormDialog.py", line 45, in _onCancel
    self.restoreAllSavedWidgetStates()
  File "C:\Users\pam62425\AppData\Local\mambaforge\envs\eqt_env\Lib\site-packages\eqt\ui\FormDialog.py", line 260, in restoreAllSavedWidgetStates
    self.formWidget.restoreAllSavedWidgetStates()
  File "C:\Users\pam62425\AppData\Local\mambaforge\envs\eqt_env\Lib\site-packages\eqt\ui\UIFormWidget.py", line 474, in restoreAllSavedWidgetStates
    self.applyWidgetStates(self.default_widget_states)
  File "C:\Users\pam62425\AppData\Local\mambaforge\envs\eqt_env\Lib\site-packages\eqt\ui\UIFormWidget.py", line 440, in applyWidgetStates
    raise KeyError(f"states={set(states)} do not match form widgets ({set(self.widgets)})")
KeyError: "states={'userinput_field', 'Widget 1_label', 'Button Remove w1_field', 'Button remove vertical_field', 'Widget 2_field', 'Button Remove Spanning_field', 'Widget 2_label', 'ok_cancel_instructions_field', 'Widget 3_field', 'userinput_label', 'Widget 3_label', 'input_title_field', 'Widget 1_field'} do not match form widgets ({'userinput_field', 'Button Remove w1_field', 'Button remove vertical_field', 'Widget 2_field', 'Button Remove Spanning_field', 'ok_cancel_instructions_field', 'Widget 3_field', 'userinput_label', 'Widget 3_label', 'input_title_field', 'Widget 2_label'})"

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions