[Task] Solve the issue with clearing GSAS workspaces
-
Identify the issue.
- When deleting all workspaces from the
Bragg Workspaces
tree and trying to change unit afterwards, ADDIE will crash, raising error like below,
Traceback (most recent call last): File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/main.py", line 692, in evt_switch_bragg_unit rietveld_event_handler.switch_bragg_unit(main_window=self) File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/rietveld/event_handler.py", line 377, in switch_bragg_unit assert len(ws_group_list) > 0, 'At least 1 GSS file must be selected.' AssertionError: At least 1 GSS file must be selected.
- From the error message, we see that the cause for the issue is that the unit changing operation is expecting at least one workspace to be selected. However, if we already delete all workspaces, such a condition will never be met and therefore we encounter with issue.
- When deleting all workspaces from the
-
Solve the issue.
-
We want to make sure that once we delete all workspaces from the tree, all the checkboxes/buttons will be greyed out and the canvas should be cleared.
-
Search for
Delete workspace
->addie/rietveld/braggtree.py
->self.do_delete_gsas
-
self.do_delete_gsas
defines what will happen when we click on theDelete workspace
option from the right click menu. Therefore, in this part of codes, we want to add (to the end of the function) the checking for the number of still existing workspaces. If this number is one (since there will always be a workspace calledworkspaces
), we then want to grey out all checkboxes/buttons and clear the canvas. -
The following codes can be introduced in the very end of the function
do_delete_gsas
inaddie/rietveld/braggtree.py
,
if len(self._mainNodeDict) == 1: event_handler.do_clear_bragg_canvas(self._main_window) self._main_window._onCanvasGSSBankList = [] event_handler.check_rietveld_widgets(self._main_window)
The
self._main_window
is defined at the very bottom ofaddie/rietveld/braggtree.py
.The last two lines refer to the solution to issue #16 (closed).
-
-