Skip to content

Commit c32af55

Browse files
committed
Add name to widgets
1 parent 1af4e64 commit c32af55

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/napari_matplotlib/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111
from matplotlib.figure import Figure
1212
from qtpy.QtGui import QIcon
13-
from qtpy.QtWidgets import QVBoxLayout, QWidget
13+
from qtpy.QtWidgets import QLabel, QVBoxLayout, QWidget
1414

1515
from .util import Interval, from_napari_css_get_size_of
1616

@@ -36,6 +36,9 @@ class BaseNapariMPLWidget(QWidget):
3636
methods for working with napari layers.
3737
"""
3838

39+
#: Name of widget. If not None, will be displayed as a title in the widget.
40+
name: Optional[str] = None
41+
3942
def __init__(
4043
self,
4144
parent: Optional[QWidget] = None,
@@ -52,6 +55,8 @@ def __init__(
5255
self._replace_toolbar_icons()
5356

5457
self.setLayout(QVBoxLayout())
58+
if self.name is not None:
59+
self.layout().addWidget(QLabel(self.name))
5560
self.layout().addWidget(self.toolbar)
5661
self.layout().addWidget(self.canvas)
5762

src/napari_matplotlib/histogram.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class HistogramWidget(NapariMPLWidget):
1919

2020
n_layers_input = Interval(1, 1)
2121
input_layer_types = (napari.layers.Image,)
22+
name = "Histogram"
2223

2324
def __init__(
2425
self,

src/napari_matplotlib/scatter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class ScatterWidget(ScatterBaseWidget):
7575
of a scatter plot, to avoid too many scatter points.
7676
"""
7777

78+
name = "Scatter widget"
7879
n_layers_input = Interval(2, 2)
7980
input_layer_types = (napari.layers.Image,)
8081

@@ -104,6 +105,7 @@ class FeaturesScatterWidget(ScatterBaseWidget):
104105
Widget to scatter data stored in two layer feature attributes.
105106
"""
106107

108+
name = "Features scatter"
107109
n_layers_input = Interval(1, 1)
108110
# All layers that have a .features attributes
109111
input_layer_types = (

src/napari_matplotlib/slice.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class SliceWidget(NapariMPLWidget):
1919
Plot a 1D slice along a given dimension.
2020
"""
2121

22+
name = "1D slice"
2223
n_layers_input = Interval(1, 1)
2324
input_layer_types = (napari.layers.Image,)
2425

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy