Sequence issue in QProgressDialog
I have an app that first displays a splash page with a QPushButton labeled "Start" on it. Nothing happens until user clicks the Start button. Once clicked, the splash page disappears and the data files/modules begin loading -- and there is about a 4 second delay until the Mainwindow appears. I wanted to add either a QprogressBar or a QProgressDialog, and chose the QProgressDialog only because it seems to do what I want without adding a widget somewhere. I don't know if I made the right choice.
Here is my code for the Start Button:
Code:
def start(self):
self.accept()
self.progress.setMinimum(0)
self.progress.setMaximum(100)
self.progress.setLabelText("Loading file")
self.progress.setCancelButton(None)
self.progress.setValue(self.step)
if self.timer.isActive():
self.timer.stop()
else:
self.timer.start(100, self)
def timerEvent(self, event):
if self.step >= 100:
self.timer.stop()
return
self.step = self.step + 10
self.progress.setValue(self.step)
My problem is the progress bar shows up AFTER the Mainwindow has appeared -- likely because the "self.accept" starts the file loading process and when it finishes, the progress bar appears. I read about "starting another thread" issues, but don't understand and don't know if it's a good idea.
1. How do I fix?
2. Should some of the QProgressDialog setup code (minimum, max, set label, etc) be moved to my init section or is it in the right place?
3. Is the QProgressDialog process set up correctly? ie., with the timer, etc
4. Currently, my timer is simply based on showing the bar for about 4 seconds. How do I link the timer to the actual time between the Splash page disappearing and the Mainwindow appearing?
thanks
Re: Sequence issue in QProgressDialog
RESOLVED: I changed the flow of my loading files process and changed to a QProgressBar on the Splash page, and it works fine. Thanks for looking
Re: Sequence issue in QProgressDialog
Was going to reply with that suggestion, but my Python skills aren't strong enough to explain how to implement it.