From 31f9bf81f3e4825484860f771127985db187078d Mon Sep 17 00:00:00 2001 From: Jessy Lauer <30733203+jeylau@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:40:09 +0200 Subject: [PATCH] Silly hack to force some refresh to happen --- src/napari_deeplabcut/_widgets.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/napari_deeplabcut/_widgets.py b/src/napari_deeplabcut/_widgets.py index 2979d8a..c4a2c74 100644 --- a/src/napari_deeplabcut/_widgets.py +++ b/src/napari_deeplabcut/_widgets.py @@ -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( @@ -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() @@ -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()