Skip to content

Commit

Permalink
Make node marker and label sizes configurable via preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
talmo committed Dec 16, 2024
1 parent fd4ef81 commit 820e145
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,17 +656,18 @@ def prev_vid():
key="edge style",
)

# XXX
add_submenu_choices(
menu=viewMenu,
title="Node Marker Size",
options=(1, 2, 4, 6, 8, 12),
options=prefs["node marker sizes"],
key="marker size",
)

add_submenu_choices(
menu=viewMenu,
title="Node Label Size",
options=(6, 12, 18, 24, 36),
options=prefs["node label sizes"],
key="node label size",
)

Expand Down
16 changes: 9 additions & 7 deletions sleap/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Preferences(object):
"node label size": 12,
"show non-visible nodes": True,
"share usage data": True,
"node marker sizes": (1, 2, 3, 4, 6, 8, 12),
"node label sizes": (6, 9, 12, 18, 24, 36),
}
_filename = "preferences.yaml"

Expand All @@ -43,14 +45,14 @@ def load_(self):
"""Load preferences from file (regardless of whether loaded already)."""
try:
self._prefs = util.get_config_yaml(self._filename)
if not hasattr(self._prefs, "get"):
self._prefs = self._defaults
else:
self._prefs["trail length"] = self._prefs.get(
"trail length", self._defaults["trail length"]
)
except FileNotFoundError:
self._prefs = self._defaults
pass

self._prefs = self._prefs or {}

for k, v in self._defaults.items():
if k not in self._prefs:
self._prefs[k] = v

def save(self):
"""Save preferences to file."""
Expand Down

0 comments on commit 820e145

Please sign in to comment.