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 7672609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:19:31+00:00 2026-05-31T16:19:31+00:00

I modified this simple countdown timer form here: https://github.com/lunaryorn/snippets/blob/master/qt4/countdown.py as follows. Now I want

  • 0

I modified this simple countdown timer form here: https://github.com/lunaryorn/snippets/blob/master/qt4/countdown.py as follows. Now I want to have a background image behind the countdown timer. Any ideas how to do this?

#!/usr/bin/python

import sys

from PyQt4.QtCore import Qt, QTime, QTimer
from PyQt4.QtGui import QApplication, QLabel, QPixmap



class CountdownWidget(QLabel):
    def __init__(self, countdown, parent=None):
        QLabel.__init__(self, parent)
        self.countdown = countdown
        self.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter);
        #self.setPixmap(QPixmap('/tmp/test.png'));
        self.setStyleSheet("QLabel {font-size : 400px; color : blue; }");
        self.setText(str(self.countdown))
        # setup the countdown timer
        self.timer = QTimer(self)
        self.timer.timeout.connect(self._update_time)

    def start(self):
        # update the display every second
        self.timer.start(1000)

    def _update_time(self):
        # this gets called every seconds
        # adjust the remaining time
        #self.countdown = self.countdown.addSecs(-1)
        self.countdown = self.countdown -1
        # if the remaining time reached zero, stop the timer
        if self.countdown <= 0:
            self.timer.stop()
        # update the display
        self.setText(str(self.countdown))
        #self.setPixmap(QPixmap('/tmp/test.png')); #<--- doesn't work


def main():
    app = QApplication(sys.argv)
    widget = CountdownWidget(30)
    widget.start()
    widget.show()
    app.exec_()


if __name__ == '__main__':
    main()
  • 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-05-31T16:19:32+00:00Added an answer on May 31, 2026 at 4:19 pm

    Put the image as a CSS background:

    self.setStyleSheet("QLabel {font-size : 400px; color : blue; background-image: url('tmp/test.jpg');}");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple Lucene search code (Modified from http://www.lucenetutorial.com/lucene-in-5-minutes.html ) class Program {
I have this timer function, it gives me following exception. Collection was modified; enumeration
I am supposed to modified this Sierpinski's triangle program to count the number of
Is there any known attack on this modified version of Yahalom? Cannot find anything...
I request a website header, however, there is not Last-Modified info in this http
I ran across this chunk of code (modified) in our application, and am confused
This is a question regarding the timezone specified in the Expires and Last-Modified HTTP
I'm currently struggling with this Collection was modified; enumeration operation may not execute issue.
This is an example from a book, a bit modified. It seems like sessions
I thought this would be very easy. I downloaded the JDK, extracted src.zip, modified

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.