Skip to content

Commit

Permalink
Add logic inside class it's being executed in
Browse files Browse the repository at this point in the history
  • Loading branch information
Jvshen committed Oct 9, 2024
1 parent 5b1440a commit 8a54592
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sleap/gui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,10 @@ def exportFullPackage(self):
def previousLabeledFrame(self):
"""Goes to labeled frame prior to current frame."""
self.execute(GoPreviousLabeledFrame)
self.state["instance"] = None


def nextLabeledFrame(self):
"""Goes to labeled frame after current frame."""
self.execute(GoNextLabeledFrame)
self.state["instance"] = None

def nextUserLabeledFrame(self):
"""Goes to next labeled frame with user instances."""
Expand Down Expand Up @@ -405,7 +403,6 @@ def nextTrackFrame(self):
def gotoFrame(self):
"""Shows gui to go to frame by number."""
self.execute(GoFrameGui)
self.state["instance"] = None

def selectToFrame(self):
"""Shows gui to go to frame by number."""
Expand All @@ -414,17 +411,14 @@ def selectToFrame(self):
def gotoVideoAndFrame(self, video: Video, frame_idx: int):
"""Activates video and goes to frame."""
NavCommand.go_to(self, frame_idx, video)
self.state["instance"] = None

def nextView(self):
"""Goes to next view."""
self.execute(GoAdjacentView, prev_or_next="next")
self.state["instance"] = None

def prevView(self):
"""Goes to previous view."""
self.execute(GoAdjacentView, prev_or_next="prev")
self.state["instance"] = None

# Editing Commands

Expand Down Expand Up @@ -1603,6 +1597,10 @@ def _get_frame_iterator(context: CommandContext):
reverse=True,
)

def do_action(cls, context: CommandContext, params: dict):
super().do_action(context)
context.state["instance"] = None


class GoNextLabeledFrame(GoIteratorCommand):
@staticmethod
Expand All @@ -1611,6 +1609,9 @@ def _get_frame_iterator(context: CommandContext):
context.state["video"], from_frame_idx=context.state["frame_idx"]
)

def do_action(cls, context: CommandContext, params: dict):
super().do_action(context)
context.state["instance"] = None

class GoNextUserLabeledFrame(GoIteratorCommand):
@staticmethod
Expand Down Expand Up @@ -1696,6 +1697,7 @@ class GoFrameGui(NavCommand):
@classmethod
def do_action(cls, context: "CommandContext", params: dict):
cls.go_to(context, params["frame_idx"])
context.state["instance"] = None

@classmethod
def ask(cls, context: "CommandContext", params: dict) -> bool:
Expand Down Expand Up @@ -1752,6 +1754,7 @@ def do_action(cls, context: CommandContext, params: dict):

context.state["video"] = new_video
context.state["frame_idx"] = frame_idx
context.state["instance"] = None


# Editing Commands
Expand Down

0 comments on commit 8a54592

Please sign in to comment.