how to show .gif in QLabel Python

0

Good morning I would like to know if there is any way in which I can show a file.gif in a qlabel.

Currently I've only tried this:

from PyQt5.QtWidgets import QMainWindow,QApplication,QLabel



class Nueva(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.l = QLabel(self)
        self.l.resize(150,150)
        self.l.setStyleSheet('Background-image:{};'.format('anima.gif'))






app = QApplication([])
n = Nueva()
n.resize(900,600)
n.show()
app.exec_()

but it did not work I appreciate your help

    
asked by Mystic_Force 16.10.2018 в 17:44
source

1 answer

0

The solution is to implement a QMovie within a QLabel .

from PyQt5.QtWidgets import QMainWindow,QApplication,QLabel
from PyQt5.Qt import QMovie



class Nueva(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.l = QLabel(self)
        self.l.resize(150,150)
        self.movi = QMovie("anima.gif")
        self.l.setMovie(self.movi)
        self.movi.start()





app = QApplication([])
n = Nueva()
n.resize(900,600)
n.show()
app.exec_()
    
answered by 17.10.2018 / 05:30
source