From dc95f763328e158b8066ff5440c8325fbb17a957 Mon Sep 17 00:00:00 2001 From: Edward Barnard Date: Fri, 30 Mar 2018 10:29:45 -0700 Subject: [PATCH] When a floating Dock window is closed, the dock is now returned to its original DockArea --- pyqtgraph/dockarea/DockArea.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyqtgraph/dockarea/DockArea.py b/pyqtgraph/dockarea/DockArea.py index a55d6bb0..b7b0659e 100644 --- a/pyqtgraph/dockarea/DockArea.py +++ b/pyqtgraph/dockarea/DockArea.py @@ -46,6 +46,10 @@ class DockArea(Container, QtGui.QWidget, DockDrop): """ if dock is None: dock = Dock(**kwds) + + # store original area that the dock will return to when un-floated + if not self.temporary: + dock.orig_area = self ## Determine the container to insert this dock into. @@ -371,5 +375,11 @@ class TempAreaWindow(QtGui.QWidget): self.layout.addWidget(area) def closeEvent(self, *args): + # restore docks to their original area + docks = self.dockarea.findAll()[1] + for dock in docks.values(): + if hasattr(dock, 'orig_area'): + dock.orig_area.addDock(dock, ) + # clear dock area, and close remaining docks self.dockarea.clear() QtGui.QWidget.closeEvent(self, *args)