Skip to content

Commit

Permalink
Silly hack to force some refresh to happen
Browse files Browse the repository at this point in the history
  • Loading branch information
jeylau committed Jun 12, 2024
1 parent 6e698c0 commit 31f9bf8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/napari_deeplabcut/_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def _load_dataframe(self):
if points_layer is None or ~np.any(points_layer.data):
return

self.viewer.window.add_dock_widget(self, name="Trajectory plot", area="right")
self.show() # Silly hack so the window does not hang the first time it is shown
self.hide()

self.df = _form_df(
Expand Down Expand Up @@ -684,6 +684,13 @@ def __init__(self, napari_viewer):
QTimer.singleShot(10, self.start_tutorial)
self.settings.setValue("first_launch", False)

# Slightly delay docking so it is shown underneath the KeypointsControls widget
QTimer.singleShot(10, self.silently_dock_matplotlib_canvas)

def silently_dock_matplotlib_canvas(self):
self.viewer.window.add_dock_widget(self._matplotlib_canvas, name="Trajectory plot", area="right")
self._matplotlib_canvas.hide()

@cached_property
def settings(self):
return QSettings()
Expand Down Expand Up @@ -797,6 +804,7 @@ def _show_trails(self, state):
def _show_matplotlib_canvas(self, state):
if Qt.CheckState(state) == Qt.CheckState.Checked:
self._matplotlib_canvas.show()
self.viewer.window._qt_window.update()
else:
self._matplotlib_canvas.hide()

Expand Down

0 comments on commit 31f9bf8

Please sign in to comment.