Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the problem #296

Merged
merged 8 commits into from
Jan 18, 2024
5 changes: 4 additions & 1 deletion napari_clusters_plotter/_Qt_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def measurements_container_and_list():
return properties_container, properties_list


def layer_container_and_selection():
def layer_container_and_selection(viewer=None):
"""
Create a container and a dropdown widget to select the layer.

Expand All @@ -67,6 +67,9 @@ def layer_container_and_selection():
layer_select = create_widget(annotation=Layer, label="layer")
layer_selection_container.layout().addWidget(layer_select.native)

if viewer is not None and viewer.layers.selection.active is not None:
layer_select.value = viewer.layers.selection.active
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm speculating this crashes when two layers are selected in napari?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and at the moment when you select two layers the selection.active returns none. I’m guessing that might change some time in the future though but I’m not sure


return layer_selection_container, layer_select


Expand Down
2 changes: 1 addition & 1 deletion napari_clusters_plotter/_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, napari_viewer):
(
layer_selection_container,
self.layer_select,
) = layer_container_and_selection()
) = layer_container_and_selection(viewer=self.viewer)

# widget for the selection of properties to perform clustering
(
Expand Down
2 changes: 1 addition & 1 deletion napari_clusters_plotter/_dimensionality_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, napari_viewer):
(
layer_selection_container,
self.layer_select,
) = layer_container_and_selection()
) = layer_container_and_selection(viewer=self.viewer)

# select properties of which to produce a dimensionality reduced version
(
Expand Down
2 changes: 1 addition & 1 deletion napari_clusters_plotter/_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def manual_clustering_method(inside):
(
layer_selection_container,
self.layer_select,
) = layer_container_and_selection()
) = layer_container_and_selection(viewer=self.viewer)

# widget for the selection of axes
axes_container = QWidget()
Expand Down
Loading