Skip to content

Commit 7c89a39

Browse files
Timokleiajeylau
andauthored
Shortcuts SVG File added in Napari GUI (#104)
* Add files via upload * Update _widgets.py * Update _widgets.py * Update _widgets.py * Update _widgets.py * Update _widgets.py * Update _widgets.py * Update _widgets.py * Update _widgets.py * Delete src/napari_deeplabcut/assets/black/napari_shortcuts.png * Update _widgets.py * Add files via upload * Update _widgets.py * Update _widgets.py to move image path to Shortcuts Class * Update MANIFEST.in to add shortcuts image location * Update _widgets.py to add display_shortcuts(self) def * Fix some bugs * Update svg path --------- Co-authored-by: Jessy Lauer <[email protected]>
1 parent 8916818 commit 7c89a39

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include LICENSE
22
include README.md
33
include src/napari_deeplabcut/styles/*.mplstyle
4+
include src/napari_deeplabcut/assets/napari_shortcuts.svg
45

56
recursive-exclude * __pycache__
67
recursive-exclude * *.py[co]

src/napari_deeplabcut/_widgets.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from napari.utils.history import get_save_history, update_save_history
2525
from qtpy.QtCore import Qt, QTimer, Signal, QPoint, QSettings, QSize
2626
from qtpy.QtGui import QPainter, QAction, QCursor, QIcon
27+
from qtpy.QtSvgWidgets import QSvgWidget
2728
from qtpy.QtWidgets import (
2829
QButtonGroup,
2930
QCheckBox,
@@ -65,18 +66,16 @@ def __init__(self, parent):
6566
super().__init__(parent=parent)
6667
self.setParent(parent)
6768
self.setWindowTitle("Shortcuts")
69+
70+
image_path = str(Path(__file__).parent / "assets" / "napari_shortcuts.svg")
71+
6872
vlayout = QVBoxLayout()
69-
shortcuts = """
70-
* `2` and `3`, to switch between labeling and selection mode
71-
* `4`, to enable pan & zoom
72-
* `M`, to cycle through regular (sequential), quick, and loop annotation mode
73-
* `E`, to enable edge coloring
74-
* `F`, to toggle between animal and body part color scheme
75-
* `V`, to toggle visibility of the selected layer
76-
* `backspace`, to delete a point
77-
"""
78-
message = QLabel(shortcuts)
79-
vlayout.addWidget(message)
73+
background_widget = QWidget()
74+
background_widget.setStyleSheet("background-color: white;")
75+
svg_widget = QSvgWidget(image_path)
76+
vlayout.addWidget(background_widget)
77+
vlayout.addWidget(svg_widget)
78+
vlayout.setContentsMargins(0, 0, 0, 0)
8079
self.setLayout(vlayout)
8180

8281

@@ -643,9 +642,9 @@ def __init__(self, napari_viewer):
643642
self.viewer.window.view_menu.addAction(launch_tutorial)
644643

645644
# Add action to view keyboard shortcuts
646-
display_shortcuts = QAction("&Shortcuts", self)
647-
display_shortcuts.triggered.connect(self.display_shortcuts)
648-
self.viewer.window.help_menu.addAction(display_shortcuts)
645+
display_shortcuts_action = QAction("&Shortcuts", self)
646+
display_shortcuts_action.triggered.connect(self.display_shortcuts)
647+
self.viewer.window.help_menu.addAction(display_shortcuts_action)
649648

650649
# Hide some unused viewer buttons
651650
self.viewer.window._qt_viewer.viewerButtons.gridViewButton.hide()

src/napari_deeplabcut/assets/napari_shortcuts.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)