Skip to content

Commit

Permalink
MAINT: Validate only 1 tonic input widget is added
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilo9999 committed May 22, 2024
1 parent 577b317 commit 37cde88
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion hnn_core/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,10 @@ def add_drive_widget(drive_type, drive_boxes, drive_widgets, drives_out,
sync_evinput=False):
"""Add a widget for a new drive."""

# Check only adds 1 tonic input widget
if drive_type == "Tonic" and not _is_valid_add_tonic_input(drive_widgets):
return

style = {'description_width': '125px'}
drives_out.clear_output()
if not prespecified_drive_data:
Expand Down Expand Up @@ -1132,7 +1136,7 @@ def add_drive_widget(drive_type, drive_boxes, drive_widgets, drives_out,
sync_evinput=sync_evinput
)
elif drive_type == 'Tonic':
name = drive_type + str(len(drive_boxes))
name = drive_type
drive, drive_box = _get_tonic_widget(
name,
layout,
Expand Down Expand Up @@ -1582,6 +1586,13 @@ def handle_backend_change(backend_type, backend_config, mpi_cmd, n_jobs):
display(n_jobs)


def _is_valid_add_tonic_input(drive_widgets):
for drive in drive_widgets:
if "Tonic" in drive['name']:
return False
return True


def launch():
"""Launch voila with hnn_widget.ipynb.
Expand Down

0 comments on commit 37cde88

Please sign in to comment.