@@ -34,6 +34,12 @@ class NapariMPLWidget(QWidget):
34
34
advantage of this sub-classes should implement the ``clear()`` and
35
35
``draw()`` methods.
36
36
37
+ When both the z-step and layer selection is changed, ``clear()`` is called
38
+ and if the number a type of selected layers are valid for the widget
39
+ ``draw()`` is then called. When layer selection is changed ``on_update_layers()``
40
+ is also called, which can be useful e.g. for updating a layer list in a
41
+ selection widget.
42
+
37
43
Attributes
38
44
----------
39
45
viewer : `napari.Viewer`
@@ -105,12 +111,12 @@ def _setup_callbacks(self) -> None:
105
111
# Layer selection changed in viewer
106
112
self .viewer .layers .selection .events .changed .connect (self .update_layers )
107
113
108
- def update_layers (self , event : napari .utils .events .Event ) -> None :
114
+ def _update_layers (self , event : napari .utils .events .Event ) -> None :
109
115
"""
110
116
Update the ``layers`` attribute with currently selected layers and re-draw.
111
117
"""
112
118
self .layers = list (self .viewer .layers .selection )
113
- self ._on_update_layers ()
119
+ self .on_update_layers ()
114
120
self ._draw ()
115
121
116
122
def _draw (self ) -> None :
@@ -165,10 +171,9 @@ def apply_napari_colorscheme(ax: Axes) -> None:
165
171
ax .tick_params (axis = "x" , colors = "white" )
166
172
ax .tick_params (axis = "y" , colors = "white" )
167
173
168
- def _on_update_layers (self ) -> None :
174
+ def on_update_layers (self ) -> None :
169
175
"""
170
- Function is called when self.layers is updated via
171
- ``self.update_layers()``.
176
+ Called when the selected layers are updated.
172
177
173
178
This is a no-op, and is intended for derived classes to override.
174
179
"""
0 commit comments