[PyQt] QMovie causes runtime error when applied to QLabel

Phil Thompson phil at riverbankcomputing.com
Thu Aug 14 22:28:56 BST 2008


On Wed, 13 Aug 2008 12:05:12 +0200, Sven Grunewaldt <strayer at olle-orks.org>
wrote:
> Hi,
> 
> I want to display an image in a QLabel and while downloading it, I want
> to display the usual nice ajax gif.
> After a little bit of searching around I found QMovie(), but whenever I
> apply it to a QLabel I get a runtime error on the pythonw.exe :(
> 
> I got the loading gif from http://www.ajaxload.info/ and attached it to
> the email.
> 
> Code:
> import sys
> from PyQt4.QtGui import *
> 
> app = QApplication(sys.argv)
> 
> label = QLabel("Test", None)
> 
> gif = QMovie()
> gif.setFileName("test.gif")
> img = QImage()
> img.load("test.gif")
> 
> # Causes runtime error
> # label.setMovie(gif)
> 
> # Works, but is not animated
> label.setPixmap(QPixmap.fromImage(img))
> 
> label.show()
> app.exec_()

Works fine for me, if you add the missing gif.start(), and your Qt has GIF
support.

Phil



More information about the PyQt mailing list