Prevent dialog from moving label/bar widgets on resize when nested

This commit is contained in:
Luke Campagnola 2017-10-04 09:01:51 -07:00
parent e6507f8601
commit 7c1a6ecb1a
2 changed files with 8 additions and 2 deletions

View File

@ -13,11 +13,11 @@ app = QtGui.QApplication([])
def runStage(i): 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: with pg.ProgressDialog("Running stage %s.." % i, maximum=100, nested=True) as dlg:
for j in range(100): for j in range(100):
time.sleep(0.03) time.sleep(0.02)
dlg += 1 dlg += 1
if dlg.wasCanceled(): if dlg.wasCanceled():
print("Canceled stage %s" % i) print("Canceled stage %s" % i)

View File

@ -184,6 +184,12 @@ class ProgressDialog(QtGui.QProgressDialog):
return self._nestableWidgets 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 ## wrap all other functions to make sure they aren't being called from non-gui threads
def setValue(self, val): def setValue(self, val):