Skip to content

Commit

Permalink
fix: widgets should have optional arg for updating other widgets (#362)
Browse files Browse the repository at this point in the history
otherwise PyTest would give error (though doesn't fail tests)
  • Loading branch information
qin-yu authored Nov 21, 2024
1 parent 37f8f1c commit c3a0b36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plantseg/viewer_napari/widgets/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def to_choices(cls):
"widget_type": "RadioButtons",
"orientation": "horizontal",
},
update_other_widgets={
"visible": False,
"tooltip": "To allow toggle the update of other widgets in unit tests; invisible to users.",
},
)
def widget_open_file(
path_mode: str = PathMode.FILE.value,
Expand All @@ -88,6 +92,7 @@ def widget_open_file(
new_layer_name: str = "",
dataset_key: str | None = None,
stack_layout: str = ImageLayout.ZYX.value,
update_other_widgets: bool = True,
) -> None:
"""Open a file and return a napari layer."""

Expand All @@ -96,6 +101,8 @@ def widget_open_file(
elif layer_type == ImageType.LABEL.value:
semantic_type = SemanticType.SEGMENTATION

widgets_to_update = [widget_set_voxel_size.layer]

return schedule_task(
import_image_task,
task_kwargs={
Expand All @@ -105,7 +112,7 @@ def widget_open_file(
"semantic_type": semantic_type,
"stack_layout": stack_layout,
},
widgets_to_update=[widget_set_voxel_size.layer],
widgets_to_update=widgets_to_update if update_other_widgets else [],
)


Expand Down
1 change: 1 addition & 0 deletions tests/widgets/test_widget_open_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_widget_open_file(make_napari_viewer_proxy, path_h5):
new_layer_name="test_raw",
dataset_key="/raw",
stack_layout="ZYX",
update_other_widgets=False,
)
napari.run()

Expand Down

0 comments on commit c3a0b36

Please sign in to comment.