-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathplugin_helper.py
More file actions
79 lines (61 loc) · 2.53 KB
/
plugin_helper.py
File metadata and controls
79 lines (61 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
"""Tiny plugin showing link to documentation and about page."""
import pathlib
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import napari
# Qt
from qtpy.QtCore import QSize
from qtpy.QtGui import QIcon, QPixmap
from qtpy.QtWidgets import QVBoxLayout, QWidget
# local
from napari_cellseg3d import interface as ui
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.{'0.2.0'}\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)