22
22
23
23
class NapariMPLWidget (QWidget ):
24
24
"""
25
- Base Matplotlib canvas. Widget that can be embedded as a napari widget .
25
+ Widget containing a Matplotlib canvas and toolbar .
26
26
27
- This creates a single FigureCanvas, which contains a single Figure.
28
- It is not responsible for creating any Axes, because different widgets
29
- may want to implement different subplot layouts.
27
+ This creates a single FigureCanvas, which contains a single
28
+ `~matplotlib.figure.Figure`, and an associated toolbar.
29
+ It is not responsible for creating any Axes, because different
30
+ widgets may want to implement different subplot layouts.
30
31
31
32
This class also handles callbacks to automatically update figures when
32
33
the layer selection or z-step is changed in the napari viewer. To take
@@ -60,12 +61,12 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
60
61
self .layout ().addWidget (self .toolbar )
61
62
self .layout ().addWidget (self .canvas )
62
63
63
- self .setup_callbacks ()
64
+ self ._setup_callbacks ()
64
65
self .layers : List [napari .layers .Layer ] = []
65
66
66
- # Accept any number of input layers by default
67
+ #: Number of layers taken as input
67
68
n_layers_input = Interval (None , None )
68
- # Accept any type of input layer by default
69
+ #: Type of layer taken as input
69
70
input_layer_types : Tuple [napari .layers .Layer , ...] = (napari .layers .Layer ,)
70
71
71
72
@property
@@ -83,17 +84,17 @@ def n_selected_layers(self) -> int:
83
84
@property
84
85
def current_z (self ) -> int :
85
86
"""
86
- Current z-step of the viewer.
87
+ Current z-step of the napari viewer.
87
88
"""
88
89
return self .viewer .dims .current_step [0 ]
89
90
90
- def setup_callbacks (self ) -> None :
91
+ def _setup_callbacks (self ) -> None :
91
92
"""
92
93
Sets up callbacks.
93
94
94
- Sets up callbacks for:
95
- - Layer selection changing
96
- - z-step changing
95
+ Sets up callbacks for when :
96
+ - Layer selection is changed
97
+ - z-step is changed
97
98
"""
98
99
# z-step changed in viewer
99
100
self .viewer .dims .events .current_step .connect (self ._draw )
@@ -102,7 +103,7 @@ def setup_callbacks(self) -> None:
102
103
103
104
def update_layers (self , event : napari .utils .events .Event ) -> None :
104
105
"""
105
- Update the layers attribute with currently selected layers and re-draw.
106
+ Update the `` layers`` attribute with currently selected layers and re-draw.
106
107
"""
107
108
self .layers = list (self .viewer .layers .selection )
108
109
self ._on_update_layers ()
@@ -145,7 +146,7 @@ def add_single_axes(self) -> None:
145
146
146
147
@staticmethod
147
148
def apply_napari_colorscheme (ax : Axes ) -> None :
148
- """Apply napari-compatible colorscheme to an axes object ."""
149
+ """Apply napari-compatible colorscheme to an Axes ."""
149
150
# changing color of axes background to transparent
150
151
ax .set_facecolor ("none" )
151
152
0 commit comments