Skip to content

Commit

Permalink
Add Color by Instance Group preference saving
Browse files Browse the repository at this point in the history
  • Loading branch information
Jvshen committed Oct 18, 2024
1 parent b55d4ef commit 2088716
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def closeEvent(self, event):
prefs["color predicted"] = self.state["color predicted"]
prefs["trail shade"] = self.state["trail_shade"]
prefs["share usage data"] = self.state["share usage data"]
prefs["color_by_instance_group"] = self.state["color_by_instance_group"]

# Save preferences.
prefs.save()
Expand Down Expand Up @@ -253,6 +254,11 @@ def closeEvent(self, event):
self.commands.saveProject()
# accept event (closes window)
event.accept()

def _save_color_by_instance_group(self, value):
"""Update the color_by_instance_group preference and save it."""
prefs["color_by_instance_group"] = value
prefs.save()

def dragEnterEvent(self, event):
# TODO: Parse filenames and accept only if valid ext (or folder)
Expand Down Expand Up @@ -298,6 +304,8 @@ def labels(self, value):
def _initialize_gui(self):
"""Creates menus, dock windows, starts timers to update gui state."""

self.state["color_by_instance_group"] = prefs["color_by_instance_group"]

self._create_color_manager()
self._create_video_player()
self.statusBar()
Expand Down Expand Up @@ -648,6 +656,9 @@ def prev_vid():
viewMenu.addSeparator()
add_menu_check_item(viewMenu, "color predicted", "Color Predicted Instances")

add_menu_check_item(viewMenu, "color_by_instance_group", "Color by Instance Group")
self.state.connect("color_by_instance_group", lambda value: self._save_color_by_instance_group(value))

add_submenu_choices(
menu=viewMenu,
title="Color Palette",
Expand Down
1 change: 1 addition & 0 deletions sleap/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Preferences(object):
"medium step size": 10,
"large step size": 100,
"color predicted": False,
"color_by_instance_group": False,
"propagate track labels": True,
"palette": "standard",
"bold lines": False,
Expand Down

0 comments on commit 2088716

Please sign in to comment.