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

Update status message on status bar #1411

Merged
merged 7 commits into from
Jul 31, 2023
8 changes: 5 additions & 3 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,19 +1240,21 @@ def updateStatusMessage(self, message: Optional[str] = None):

if message is None:
message = ""
if len(self.labels.videos) > 1:
if len(self.labels.videos) > 0 and current_video is not None:
message += f"Video {self.labels.videos.index(current_video)+1}/"
message += f"{len(self.labels.videos)}"
message += spacer

message += f"Frame: {frame_idx+1:,}/{len(current_video):,}"
if current_video is not None:
message += f"Frame: {frame_idx+1:,}/{len(current_video):,}"

if self.player.seekbar.hasSelection():
start, end = self.state["frame_range"]
message += spacer
message += f"Selection: {start+1:,}-{end:,} ({end-start+1:,} frames)"

message += f"{spacer}Labeled Frames: "
if current_video is not None and current_video in self.labels.videos:
if current_video is not None:
message += str(
self.labels.get_labeled_frame_count(current_video, "user")
)
Expand Down
11 changes: 7 additions & 4 deletions sleap/gui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,17 +1847,17 @@ def _get_truncation_message(truncation_messages, path, video):


class RemoveVideo(EditCommand):
topics = [UpdateTopic.video, UpdateTopic.suggestions]
topics = [UpdateTopic.video, UpdateTopic.suggestions, UpdateTopic.frame]

@staticmethod
def do_action(context: CommandContext, params: dict):
videos = context.labels.videos.copy()
videos = context.labels.videos
row_idxs = context.state["selected_batch_video"]
videos_to_be_removed = [videos[i] for i in row_idxs]

# Remove selected videos in the project
for idx in row_idxs:
context.labels.remove_video(videos[idx])
for video in videos_to_be_removed:
context.labels.remove_video(video)

# Update the view if state has the removed video
if context.state["video"] in videos_to_be_removed:
Expand All @@ -1866,6 +1866,9 @@ def do_action(context: CommandContext, params: dict):
else:
context.state["video"] = None

if len(context.labels.videos) == 0:
context.app.updateStatusMessage(" ")

@staticmethod
def ask(context: CommandContext, params: dict) -> bool:
videos = context.labels.videos.copy()
Expand Down
4 changes: 4 additions & 0 deletions sleap/io/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ def get_filtered_frame_idxs(
self, video: Optional[Video] = None, filter: Text = ""
) -> Set[Tuple[int, int]]:
"""Return list of (video_idx, frame_idx) tuples matching video/filter."""
if video not in self.labels.videos:
# Set value of video to None if not present in the videos list.
video = None

if filter == "":
filter_func = lambda lf: video is None or lf.video == video
elif filter == "user":
Expand Down
Loading