Skip to content

napari_cellseg3d.code_plugins.plugin_helper

Tiny plugin showing link to documentation and about page.

Classes:

Name Description
Helper

Tiny plugin showing link to documentation and about page.

Helper

Bases: QWidget

Tiny plugin showing link to documentation and about page.

Methods:

Name Description
__init__

Creates a widget with links to documentation and about page.

build

Build the widget."".

remove_from_viewer

Remove the widget from the viewer.

Source code in napari_cellseg3d/code_plugins/plugin_helper.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class Helper(QWidget, metaclass=ui.QWidgetSingleton):
    """Tiny plugin showing link to documentation and about page."""

    def __init__(self, viewer: "napari.viewer.Viewer"):
        """Creates a widget with links to documentation and about page."""
        super().__init__()

        self.help_url = "https://adaptivemotorcontrollab.github.io/CellSeg3D/"

        self.about_url = (
            "https://wysscenter.ch/advances/3d-computer-vision-for-brain-analysis"
        )
        self.repo_url = "https://github.com/AdaptiveMotorControlLab/CellSeg3D"
        self._viewer = viewer

        logo_path = str(
            pathlib.Path(__file__).parent.resolve() / "../res/logo_alpha.png"
        )
        print(logo_path)
        image = QPixmap(logo_path)

        self.logo_label = ui.Button(func=lambda: ui.open_url(self.repo_url))
        self.logo_label.setIcon(QIcon(image))
        self.logo_label.setMinimumSize(200, 200)
        self.logo_label.setIconSize(QSize(200, 200))
        self.logo_label.setStyleSheet("QPushButton { background-color: transparent }")
        self.logo_label.setToolTip("Open Github page")

        self.info_label = ui.make_label(
            f"You are using napari-cellseg3d v{__version__}\n\n"
            f"Plugin for cell segmentation developed\n"
            f"by the Mathis Lab of Adaptive Motor Control\n\n"
            f"Code by :\nCyril Achard\nMaxime Vidal\nJessy Lauer\nMackenzie Mathis\n"
            f"\nReleased under the MIT license",
            self,
        )

        self.btn1 = ui.Button("Help...", lambda: ui.open_url(self.help_url))
        self.btn1.setToolTip("Go to documentation")

        self.btn2 = ui.Button("About...", lambda: ui.open_url(self.about_url))

        self.btnc = ui.Button("Close", self.remove_from_viewer)

        self.build()

    def build(self):
        """Build the widget.""."""
        vbox = QVBoxLayout()

        widgets = [
            self.logo_label,
            self.info_label,
            self.btn1,
            self.btn2,
            self.btnc,
        ]
        ui.add_widgets(vbox, widgets)
        self.setLayout(vbox)

    def remove_from_viewer(self):
        """Remove the widget from the viewer."""
        self._viewer.window.remove_dock_widget(self)

__init__

__init__(viewer: Viewer)

Creates a widget with links to documentation and about page.

Source code in napari_cellseg3d/code_plugins/plugin_helper.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def __init__(self, viewer: "napari.viewer.Viewer"):
    """Creates a widget with links to documentation and about page."""
    super().__init__()

    self.help_url = "https://adaptivemotorcontrollab.github.io/CellSeg3D/"

    self.about_url = (
        "https://wysscenter.ch/advances/3d-computer-vision-for-brain-analysis"
    )
    self.repo_url = "https://github.com/AdaptiveMotorControlLab/CellSeg3D"
    self._viewer = viewer

    logo_path = str(
        pathlib.Path(__file__).parent.resolve() / "../res/logo_alpha.png"
    )
    print(logo_path)
    image = QPixmap(logo_path)

    self.logo_label = ui.Button(func=lambda: ui.open_url(self.repo_url))
    self.logo_label.setIcon(QIcon(image))
    self.logo_label.setMinimumSize(200, 200)
    self.logo_label.setIconSize(QSize(200, 200))
    self.logo_label.setStyleSheet("QPushButton { background-color: transparent }")
    self.logo_label.setToolTip("Open Github page")

    self.info_label = ui.make_label(
        f"You are using napari-cellseg3d v{__version__}\n\n"
        f"Plugin for cell segmentation developed\n"
        f"by the Mathis Lab of Adaptive Motor Control\n\n"
        f"Code by :\nCyril Achard\nMaxime Vidal\nJessy Lauer\nMackenzie Mathis\n"
        f"\nReleased under the MIT license",
        self,
    )

    self.btn1 = ui.Button("Help...", lambda: ui.open_url(self.help_url))
    self.btn1.setToolTip("Go to documentation")

    self.btn2 = ui.Button("About...", lambda: ui.open_url(self.about_url))

    self.btnc = ui.Button("Close", self.remove_from_viewer)

    self.build()

build

build()

Build the widget."".

Source code in napari_cellseg3d/code_plugins/plugin_helper.py
65
66
67
68
69
70
71
72
73
74
75
76
77
def build(self):
    """Build the widget.""."""
    vbox = QVBoxLayout()

    widgets = [
        self.logo_label,
        self.info_label,
        self.btn1,
        self.btn2,
        self.btnc,
    ]
    ui.add_widgets(vbox, widgets)
    self.setLayout(vbox)

remove_from_viewer

remove_from_viewer()

Remove the widget from the viewer.

Source code in napari_cellseg3d/code_plugins/plugin_helper.py
79
80
81
def remove_from_viewer(self):
    """Remove the widget from the viewer."""
    self._viewer.window.remove_dock_widget(self)