File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def setup_callbacks(self) -> None:
8383
8484 def update_layers (self , event : napari .utils .events .Event ) -> None :
8585 """
86- Update the currently selected layers and re-draw.
86+ Update the layers attribute with currently selected layers and re-draw.
8787 """
8888 self .layers = list (self .viewer .layers .selection )
8989 self ._draw ()
Original file line number Diff line number Diff line change 44import numpy as np
55from qtpy .QtWidgets import QComboBox , QHBoxLayout , QSpinBox
66
7- from napari_matplotlib .base import SingleLayerWidget
7+ from napari_matplotlib .base import NapariMPLWidget
88
99__all__ = ["SliceWidget" ]
1010
@@ -15,6 +15,7 @@ class SliceWidget(NapariMPLWidget):
1515 """
1616 Plot a 1D slice along a given dimension.
1717 """
18+
1819 n_layers_input = 1
1920
2021 def __init__ (self , napari_viewer : napari .viewer .Viewer ):
@@ -33,8 +34,11 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
3334 self .slice_selectors [d ] = QSpinBox ()
3435 button_layout .addWidget (self .slice_selectors [d ])
3536
36- self .update_slice_selectors ()
37- self .draw ()
37+ self .update_layers (None )
38+
39+ @property
40+ def layer (self ):
41+ return self .layers [0 ]
3842
3943 @property
4044 def current_dim (self ) -> str :
@@ -88,10 +92,14 @@ def get_xy(self) -> Tuple[np.ndarray, np.ndarray]:
8892
8993 return x , y
9094
95+ def clear (self ) -> None :
96+ self .axes .cla ()
97+
9198 def draw (self ) -> None :
9299 """
93100 Clear axes and draw a 1D plot.
94101 """
102+ self .update_slice_selectors ()
95103 x , y = self .get_xy ()
96104
97105 self .axes .plot (x , y )
You can’t perform that action at this time.
0 commit comments