[PyQt] Splash screen with progress bar (was Re: Any Large PyQt
Projects?)
David Boddie
david at boddie.org.uk
Fri Feb 20 21:41:01 GMT 2009
On Fri Feb 20 16:39:11 GMT 2009, Chris Withers wrote:
> Toby Dickenson wrote:
> > * Startup time while your modules are imported. Plan to have a splash
> > screen with a progress bar :-(
>
> How do you do this with PyQt?
One way is to take advantage of the fact that the splash screen is just
a widget. You can just create a progress bar as a child widget and update
that.
For example:
app = QApplication(sys.argv)
# Create a pixmap - not needed if you have your own.
pixmap = create_pixmap(480, 320)
splash = QSplashScreen(pixmap)
progressBar = QProgressBar(splash)
progressBar.setGeometry(splash.width()/10, 8*splash.height()/10,
8*splash.width()/10, splash.height()/10)
splash.show()
for i in range(0, 100):
progressBar.setValue(i)
# Do something which takes some time.
t = time.time()
while time.time() < t + 0.1:
app.processEvents()
I hope this is enough to help you get started.
David
More information about the PyQt
mailing list