Skip to content

Commit

Permalink
Shortcuts SVG File added in Napari GUI (#104)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Timokleia and jeylau authored Oct 2, 2023
1 parent 8916818 commit 7c89a39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include LICENSE
include README.md
include src/napari_deeplabcut/styles/*.mplstyle
include src/napari_deeplabcut/assets/napari_shortcuts.svg

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
27 changes: 13 additions & 14 deletions src/napari_deeplabcut/_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from napari.utils.history import get_save_history, update_save_history
from qtpy.QtCore import Qt, QTimer, Signal, QPoint, QSettings, QSize
from qtpy.QtGui import QPainter, QAction, QCursor, QIcon
from qtpy.QtSvgWidgets import QSvgWidget
from qtpy.QtWidgets import (
QButtonGroup,
QCheckBox,
Expand Down Expand Up @@ -65,18 +66,16 @@ def __init__(self, parent):
super().__init__(parent=parent)
self.setParent(parent)
self.setWindowTitle("Shortcuts")

image_path = str(Path(__file__).parent / "assets" / "napari_shortcuts.svg")

vlayout = QVBoxLayout()
shortcuts = """
* `2` and `3`, to switch between labeling and selection mode
* `4`, to enable pan & zoom
* `M`, to cycle through regular (sequential), quick, and loop annotation mode
* `E`, to enable edge coloring
* `F`, to toggle between animal and body part color scheme
* `V`, to toggle visibility of the selected layer
* `backspace`, to delete a point
"""
message = QLabel(shortcuts)
vlayout.addWidget(message)
background_widget = QWidget()
background_widget.setStyleSheet("background-color: white;")
svg_widget = QSvgWidget(image_path)
vlayout.addWidget(background_widget)
vlayout.addWidget(svg_widget)
vlayout.setContentsMargins(0, 0, 0, 0)
self.setLayout(vlayout)


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

# Add action to view keyboard shortcuts
display_shortcuts = QAction("&Shortcuts", self)
display_shortcuts.triggered.connect(self.display_shortcuts)
self.viewer.window.help_menu.addAction(display_shortcuts)
display_shortcuts_action = QAction("&Shortcuts", self)
display_shortcuts_action.triggered.connect(self.display_shortcuts)
self.viewer.window.help_menu.addAction(display_shortcuts_action)

# Hide some unused viewer buttons
self.viewer.window._qt_viewer.viewerButtons.gridViewButton.hide()
Expand Down
1 change: 1 addition & 0 deletions src/napari_deeplabcut/assets/napari_shortcuts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c89a39

Please sign in to comment.