Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:09:07+00:00 2026-06-02T10:09:07+00:00

I would like to show a .gif animation in a QLabel widget, alongside text.

  • 0

I would like to show a .gif animation in a QLabel widget, alongside text.

The following code won’t work:

self.status_txt = QtGui.QLabel('Loading... <img src="etc/loading.gif">')

as the image won’t animate.

I tried achiving it by using a QMovie object:

self.status_txt = QtGui.QLabel("Loading...")
movie = QtGui.QMovie("etc/loading.gif")
self.status_txt.setMovie(movie)
movie.start()

But then I can’t put the animation and the text together.
Is there a different solution besides using two different labels?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:09:12+00:00Added an answer on June 2, 2026 at 10:09 am

    you can add a Layout to the label, and then add another Label with the text to that…

    self.status_txt = QtGui.QLabel()
    movie = QtGui.QMovie("etc/loading.gif")
    self.status_txt.setMovie(movie)
    movie.start()
    self.status_txt.setLayout(QtGui.QHBoxLayout())
    self.status_txt.layout().addWidget(QLabel('Loading...'))
    

    edit:

    it’s possible if you use your own version of a QLabel and a QPainter to paint the text yourself:

    from PyQt4.QtCore import QSize
    from PyQt4.QtGui import QApplication, QLabel, QMovie, QPainter, QFontMetrics
    
    class QTextMovieLabel(QLabel):
        def __init__(self, text, fileName):
            QLabel.__init__(self)
            self._text = text
            m = QMovie(fileName)
            m.start()
            self.setMovie(m)
    
        def setMovie(self, movie):
            QLabel.setMovie(self, movie)
            s=movie.currentImage().size()
            self._movieWidth = s.width()
            self._movieHeight = s.height()
    
        def paintEvent(self, evt):
            QLabel.paintEvent(self, evt)
            p = QPainter(self)
            p.setFont(self.font())
            x = self._movieWidth + 6
            y = (self.height() + p.fontMetrics().xHeight()) / 2
            p.drawText(x, y, self._text)
            p.end()
    
        def sizeHint(self):
            fm = QFontMetrics(self.font())
            return QSize(self._movieWidth + 6 + fm.width(self._text),
                    self._movieHeight)
    
        def setText(self, text):
            self._text = text
    
    if __name__ == '__main__':
        import sys
        app = QApplication(sys.argv)
        l = QTextMovieLabel('Loading...', 'loading.gif')
        l.show()
        app.exec_()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On exiting my game, I would like to show an exitscreen. The exitscreen.gif is
i have the following code and got the following problem: i would like to
i have the following code. On click i would like to change to pause
I would like to know a way that it will show a pre-load.gif in
I would like to show the value of a variable in a TextView, like
I would like to show and hide a div during hover and hover out.
I would like to show a div based on the Onclick event of an
I would like to show divs at a specific interval (10 seconds) and show
I would like to show different tabs in the top navigation of a SharePoint
I would like to Show my Messagebox in the center of its parent form.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.