0 Replies - 325 Views - Last Post: 25 August 2013 - 03:45 AM Rate Topic: -----

#1 sillygod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 23-January 13

python pyqt why jumpToImage always return False

Posted 25 August 2013 - 03:45 AM

I write a code about display an animated image(gif).
Environment: python3.2, pyqt4.10
the following is my code
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
import platform
import os
from urllib import request


class imgDisplay(QGraphicsScene):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.img = QImageReader('D:/My Pictures/2.gif')
        self.index = 0

        
        if self.img.supportsAnimation:
            super().startTimer(self.img.nextImageDelay())
            self.iter = iter(self.distractImg())

    def distractImg(self):
        for i in range(self.img.imageCount()):
            yield QPixmap.fromImageReader(self.img)
        print(self.img.jumpToImage(0))

            

    def timerEvent(self, QTimerEvent):
        super().timerEvent(QTimerEvent)
        try:
            self.addPixmap(next(self.iter))
        except:
            self.iter = iter(self.distractImg())

        self.update()



if __name__ == '__main__':
    app = QApplication(sys.argv)
    obj = imgDisplay()

    view = QGraphicsView(obj)
    view.show()

    sys.exit(app.exec_())



my question is why self.img.jumpToImage(0) in distractImg always return False. Here is the document

Is This A Good Question/Topic? 0
  • +

Page 1 of 1