From 7c1a6ecb1afcf4f1012c367380d7195732368380 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 4 Oct 2017 09:01:51 -0700 Subject: [PATCH] Prevent dialog from moving label/bar widgets on resize when nested --- examples/ProgressDialog.py | 4 ++-- pyqtgraph/widgets/ProgressDialog.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/ProgressDialog.py b/examples/ProgressDialog.py index 08cffa7e..141d2bb4 100644 --- a/examples/ProgressDialog.py +++ b/examples/ProgressDialog.py @@ -13,11 +13,11 @@ app = QtGui.QApplication([]) def runStage(i): - """Waste time for 3 seconds while incrementing a progress bar. + """Waste time for 2 seconds while incrementing a progress bar. """ with pg.ProgressDialog("Running stage %s.." % i, maximum=100, nested=True) as dlg: for j in range(100): - time.sleep(0.03) + time.sleep(0.02) dlg += 1 if dlg.wasCanceled(): print("Canceled stage %s" % i) diff --git a/pyqtgraph/widgets/ProgressDialog.py b/pyqtgraph/widgets/ProgressDialog.py index 4964771d..de3c6dc4 100644 --- a/pyqtgraph/widgets/ProgressDialog.py +++ b/pyqtgraph/widgets/ProgressDialog.py @@ -183,6 +183,12 @@ class ProgressDialog(QtGui.QProgressDialog): self._nestableWidgets = (sw, btn) return self._nestableWidgets + + def resizeEvent(self, ev): + if self._nestingReady: + # don't let progress dialog manage widgets anymore. + return + return QtGui.QProgressDialog.resizeEvent(self, ev) ## wrap all other functions to make sure they aren't being called from non-gui threads