Skip to content

Commit

Permalink
Remove no module named work error (#1956)
Browse files Browse the repository at this point in the history
* Do not always color skeletons table black

* Remove offending (possibly unneeded) line
that causes the no module named work error to print in terminal

* Remove offending (possibly unneeded) line
that causes the no module named work error to print in terminal

* Remove accidentally added changes

* Add (failing) test to ensure menu-item updates with state change

* Reconnect callback for menu-item (using lambda)

* Add (failing) test to ensure menu-item updates with state change

Do not assume inital state

* Reconnect callback for menu-item (using lambda)

---------

Co-authored-by: roomrys <[email protected]>
  • Loading branch information
roomrys and roomrys authored Sep 11, 2024
1 parent c090df3 commit e4bb444
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ def add_menu_item(menu, key: str, name: str, action: Callable):
def connect_check(key):
self._menu_actions[key].setCheckable(True)
self._menu_actions[key].setChecked(self.state[key])
self.state.connect(key, self._menu_actions[key].setChecked)
self.state.connect(
key, lambda checked: self._menu_actions[key].setChecked(checked)
)

# add checkable menu item connected to state variable
def add_menu_check_item(menu, key: str, name: str):
Expand Down
6 changes: 6 additions & 0 deletions tests/gui/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ def toggle_and_verify_visibility(expected_visibility: bool = True):
window.showNormal()
vp = window.player

# Change state and ensure menu-item check updates
color_predicted = window.state["color predicted"]
assert window._menu_actions["color predicted"].isChecked() == color_predicted
window.state["color predicted"] = not color_predicted
assert window._menu_actions["color predicted"].isChecked() == (not color_predicted)

# Enable distinct colors
window.state["color predicted"] = True

Expand Down

0 comments on commit e4bb444

Please sign in to comment.