Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make node marker and label sizes configurable via preferences #2057

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading