From eb212bcc03a2e17245d1058ef7ab50d7a6c94f7f Mon Sep 17 00:00:00 2001 From: George Dang <53052793+gtdang@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:35:28 -0400 Subject: [PATCH] fix: updated _delete_single_drive method to update titles --- hnn_core/gui/gui.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hnn_core/gui/gui.py b/hnn_core/gui/gui.py index 24917df32..32442de20 100644 --- a/hnn_core/gui/gui.py +++ b/hnn_core/gui/gui.py @@ -640,15 +640,22 @@ def _cell_layer_radio_change(value): 'value') def _delete_single_drive(self, b): + index = self.drive_accordion.selected_index + # Remove selected drive from drive lists - self.drive_boxes.pop(self.drive_accordion.selected_index) - self.drive_widgets.pop(self.drive_accordion.selected_index) + self.drive_boxes.pop(index) + self.drive_widgets.pop(index) # Rebuild the accordion collection + self.drive_accordion.titles = tuple( + t for i, t in enumerate(self.drive_accordion.titles) if i != index + ) + self.drive_accordion.selected_index = None + self.drive_accordion.children = self.drive_boxes + + # Render self._drives_out.clear_output() with self._drives_out: - self.drive_accordion.selected_index = None - self.drive_accordion.children = self.drive_boxes display(self.drive_accordion) def compose(self, return_layout=True):