Skip to content

Commit 753031d

Browse files
committed
Smarter tutorial popup
1 parent 87eb264 commit 753031d

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/napari_deeplabcut/_widgets.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from collections import defaultdict, namedtuple
33
from copy import deepcopy
44
from datetime import datetime
5-
from functools import partial
5+
from functools import partial, cached_property
66
from math import ceil, log10
77
import pandas as pd
88
from pathlib import Path
@@ -17,8 +17,8 @@
1717
from napari.layers.utils.layer_utils import _features_to_properties
1818
from napari.utils.events import Event
1919
from napari.utils.history import get_save_history, update_save_history
20-
from qtpy.QtCore import Qt, QTimer, Signal, QSize, QPoint
21-
from qtpy.QtGui import QPainter, QIcon
20+
from qtpy.QtCore import Qt, QTimer, Signal, QSize, QPoint, QSettings
21+
from qtpy.QtGui import QPainter, QIcon, QAction
2222
from qtpy.QtWidgets import (
2323
QButtonGroup,
2424
QCheckBox,
@@ -364,10 +364,21 @@ def __init__(self, napari_viewer):
364364
elif "save all layers" in action_name:
365365
self.viewer.window.file_menu.removeAction(action)
366366

367-
QTimer.singleShot(10, self.start_tutorial)
367+
# Add action to show the walkthrough again
368+
launch_tutorial = QAction("&Launch Tutorial", self)
369+
launch_tutorial.triggered.connect(self.start_tutorial)
370+
self.viewer.window.view_menu.addAction(launch_tutorial)
371+
372+
if self.settings.value("first_launch", True):
373+
QTimer.singleShot(10, self.start_tutorial)
374+
self.settings.setValue("first_launch", False)
375+
376+
@cached_property
377+
def settings(self):
378+
return QSettings()
368379

369380
def start_tutorial(self):
370-
tuto = Tutorial(self.viewer.window._qt_window.__wrapped__).show()
381+
Tutorial(self.viewer.window._qt_window.__wrapped__).show()
371382

372383
def _load_config(self):
373384
config = QFileDialog.getOpenFileName(

0 commit comments

Comments
 (0)