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

[MV] Update instance state as frame idx callback #2012

Merged
Changes from all commits
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
15 changes: 11 additions & 4 deletions sleap/gui/widgets/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
>>> vp.addInstance(instance=my_instance, color=(r, g, b))

"""

from collections import deque

# FORCE_REQUESTS controls whether we emit a signal to process frame requests
Expand Down Expand Up @@ -270,8 +271,13 @@ def update_selection_state(a, b):

self.seekbar.selectionChanged.connect(update_selection_state)

self.state.connect("frame_idx", lambda idx: self.plot())
self.state.connect("frame_idx", lambda idx: self.seekbar.setValue(idx))
def frame_idx_callback(frame_idx: int):
"""All callbacks that need to be called when frame_idx changes."""
self.plot()
self.seekbar.setValue(frame_idx)
self.state["instance"] = None

self.state.connect("frame_idx", lambda idx: frame_idx_callback(idx))
self.state.connect("instance", self.view.selectInstance)
self.state.connect("instance_group", self.view.selectInstance)

Expand Down Expand Up @@ -340,6 +346,7 @@ def _load_and_show_requested_image(self, frame_idx):
# Display image
self.view.setImage(qimage)

# TODO: Delegate to command context
def _register_shortcuts(self):
self._shortcut_triggers = dict()

Expand Down Expand Up @@ -1908,7 +1915,7 @@ def __init__(
self.track_label.setHtml(instance_label_text)

# Add nodes
for (node, point) in self.instance.nodes_points:
for node, point in self.instance.nodes_points:
if point.visible or self.show_non_visible:
node_item = QtNode(
parent=self,
Expand All @@ -1923,7 +1930,7 @@ def __init__(
self.nodes[node.name] = node_item

# Add edges
for (src, dst) in self.skeleton.edge_names:
for src, dst in self.skeleton.edge_names:
# Make sure that both nodes are present in this instance before drawing edge
if src in self.nodes and dst in self.nodes:
edge_item = QtEdge(
Expand Down
Loading