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

Fix main window hanging the first time the matplotlib widget is docked #138

Merged
merged 1 commit into from
Jun 12, 2024
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
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
Loading