Skip to content

Commit 48de4a2

Browse files
authored
Merge pull request #84 from DeepLabCut/tuto
Minor cosmetic changes
2 parents d69006b + 19f0b24 commit 48de4a2

File tree

1 file changed

+13
-42
lines changed

1 file changed

+13
-42
lines changed

src/napari_deeplabcut/_widgets.py

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,18 @@ def __init__(self, parent):
6161
self.setParent(parent)
6262
self.setWindowTitle("Tutorial")
6363
self.setModal(True)
64-
self.setWindowOpacity(0.85)
64+
self.setStyleSheet("background:#cdb4db")
65+
self.setWindowOpacity(0.95)
6566
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
6667

6768
self._current_tip = 0
6869
self._tips = [
69-
Tip('Load a folder of annotated data\n(and optionally a config file if labeling from scratch).\nAlternatively, files and folders of images can be dragged\nand dropped onto the main window.', (0.45, 0.05)),
70-
Tip('Data layers will be listed at the bottom left;\ntheir visibility can be toggled by clicking on the small eye icon.', (0.1, 0.65)),
71-
Tip('Corresponding layer controls can be found at the top left.\nSwitch between labeling and selection mode using the numeric keys 2 and 3,\nor clicking on the + or -> icons.', (0.1, 0.2)),
72-
Tip('There are three keypoint labeling modes:\nthe key M can be used to cycle between them.', (0.65, 0.05)),
73-
Tip('When done labeling, save your data by selecting the Points layer\nand hitting Ctrl+S (or File > Save Selected Layer(s)...).', (0.1, 0.65)),
74-
Tip('''Read more at <a href='https://github.com/DeepLabCut/napari-deeplabcut#usage'>napari-deeplabcut</a>''', (0.4, 0.4)),
70+
Tip("Load a folder of annotated data\n(and optionally a config file if labeling from scratch)\nfrom the menu File > Open File or Open Folder.\nAlternatively, files and folders of images can be dragged\nand dropped onto the main window.", (0.35, 0.15)),
71+
Tip("Data layers will be listed at the bottom left;\ntheir visibility can be toggled by clicking on the small eye icon.", (0.1, 0.65)),
72+
Tip("Corresponding layer controls can be found at the top left.\nSwitch between labeling and selection mode using the numeric keys 2 and 3,\nor clicking on the + or -> icons.", (0.1, 0.2)),
73+
Tip("There are three keypoint labeling modes:\nthe key M can be used to cycle between them.", (0.65, 0.05)),
74+
Tip("When done labeling, save your data by selecting the Points layer\nand hitting Ctrl+S (or File > Save Selected Layer(s)...).", (0.1, 0.65)),
75+
Tip("Read more at <a href='https://github.com/DeepLabCut/napari-deeplabcut#usage'>napari-deeplabcut</a>", (0.4, 0.4)),
7576
]
7677

7778
buttons = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Abort
@@ -80,7 +81,7 @@ def __init__(self, parent):
8081
self.button_box.rejected.connect(self.reject)
8182

8283
vlayout = QVBoxLayout()
83-
self.message = QLabel("Let's get started with a quick walkthrough!")
84+
self.message = QLabel("💡\n\nLet's get started with a quick walkthrough!")
8485
self.message.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
8586
self.message.setOpenExternalLinks(True)
8687
vlayout.addWidget(self.message)
@@ -95,7 +96,10 @@ def accept(self):
9596
if self._current_tip == 0 and "walkthrough" not in self.message.text():
9697
self.reject()
9798
tip = self._tips[self._current_tip]
98-
self.message.setText(tip.msg)
99+
msg = tip.msg
100+
if self._current_tip < 5: # No emoji in the last tip otherwise the hyperlink breaks
101+
msg = "💡\n\n" + msg
102+
self.message.setText(msg)
99103
self.count.setText(f"Tip {self._current_tip + 1}|{len(self._tips)}")
100104
self.adjustSize()
101105
xrel, yrel = tip.pos
@@ -317,17 +321,6 @@ def __init__(self, napari_viewer):
317321
)
318322
self.video_widget.setVisible(False)
319323

320-
# Add some buttons to load files and data (as a complement to drag/drop)
321-
hlayout = QHBoxLayout()
322-
load_config_button = QPushButton("Load config file")
323-
load_config_button.clicked.connect(self._load_config)
324-
hlayout.addWidget(load_config_button)
325-
326-
self.load_data_button = QPushButton("Load data folder")
327-
self.load_data_button.clicked.connect(self._load_data_folder)
328-
hlayout.addWidget(self.load_data_button)
329-
self._layout.addLayout(hlayout)
330-
331324
hlayout = QHBoxLayout()
332325
trail_label = QLabel("Show trails")
333326
self._trail_cb = QCheckBox()
@@ -382,26 +375,6 @@ def settings(self):
382375
def start_tutorial(self):
383376
Tutorial(self.viewer.window._qt_window.current()).show()
384377

385-
def _load_config(self):
386-
config = QFileDialog.getOpenFileName(
387-
self, "Select a configuration file", "", "Config files (*.yaml)"
388-
)
389-
if not config:
390-
return
391-
392-
try: # Needed to silence a late ValueError caused by the layer having no data
393-
self.viewer.open(config, plugin="napari-deeplabcut", stack=False)
394-
except ValueError:
395-
pass
396-
397-
def _load_data_folder(self):
398-
dialog = QFileDialog(self)
399-
dialog.setFileMode(QFileDialog.Directory)
400-
dialog.setViewMode(QFileDialog.Detail)
401-
if dialog.exec_():
402-
folder = dialog.selectedFiles()[0]
403-
self.viewer.open(folder, plugin="napari-deeplabcut")
404-
405378
def _move_image_layer_to_bottom(self, index):
406379
if (ind := index) != 0:
407380
self.viewer.layers.move_selected(ind, 0)
@@ -675,7 +648,6 @@ def on_insert(self, event):
675648
}
676649
)
677650
self._trail_cb.setEnabled(True)
678-
self.load_data_button.setDisabled(True)
679651

680652
# Hide the color pickers, as colormaps are strictly defined by users
681653
controls = self.viewer.window.qt_viewer.dockLayerControls
@@ -705,7 +677,6 @@ def on_remove(self, event):
705677
menu.deleteLater()
706678
menu.destroy()
707679
self._trail_cb.setEnabled(False)
708-
self.load_data_button.setDisabled(False)
709680
self.last_saved_label.hide()
710681
elif isinstance(layer, Image):
711682
self._images_meta = dict()

0 commit comments

Comments
 (0)