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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:59:00+00:00 2026-05-23T15:59:00+00:00

I have a problem with keeping a GUI responsive using PyQt and Qthreads. What

  • 0

I have a problem with keeping a GUI responsive using PyQt and Qthreads. What I do is spawn a worker Qthread from the GUI which is cpu heavy. The worker Qthread sends a signal containing a numerical value in every cycle. In the GUI the signal is connected to an update function which takes the numerical value and repaints the GUI. I use the standard Qt SIGNAL/SLOT mechanism.

This all seems in line with documentation I’ve found online regarding PyQt, GUIs and Qthreads. The problem is that the worker thread triggers the signal so frequent, that the GUI becomes very sluggish. A solution would be to have the worker thread trigger the signal less frequent, but I would like to get a fast update of the progress.

This all seems very standard stuff, and yet I can’t find a proper solution. Possibly I need to change the design?

Any help would be appreciated.

Code:

import calculator as ca

class GUI(QMainWindow):

    def __init__(self, config):
        QMainWindow.__init__(self)
        self.w_thread = WorkerThread()
        self.connect(self.w_thread, SIGNAL("update(PyQt_PyObject)"), self.update_gui)

    def start_calc(self):
        self.w_thread.start()

    def update_gui(self, progress_value):
        self.progress_value = progress_value
        self.repaint()

    def paintEvent(self, event):
        paint = QPainter()
        paint.begin(self)
        paint.drawText(300, 300, "progress: " + str(self.progress_value))
        paint.end()


class WorkerThread(QThread):

    def __init__(self):
        QThread.__init__(self)

    def __del__(self):
        self.wait()

    def run(self):
        ca.run_calculations(self)



*************** calculator.py ***************

def run_calculations(thread=None):

    while current_cycle < total_cycles:
        do_calculations()
        if current_cycle % 100 == 0:
            thread.emit(SIGNAL("update(PyQt_PyObject)"), current_progress_value)
        qApp.processEvents()
        current_cycle += 1
  • 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-23T15:59:01+00:00Added an answer on May 23, 2026 at 3:59 pm

    Adding qApp.processEvents() in the main loop of the worker thread seems to solve the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given I have a HUGE array, and a value from it. I want to
In our database model we have a Beneficiary entity. A beneficiary can be a
I have a task to convert the data design in XML format to a
If i have an ImageView that fills the screen. The ImageView background is set
We have a webapplication. At some points there is a JavaScript based WSIWYG /
I use a webkit dot net browser through c#, and I have a website
I'm making... well, it's sort of like a game in VB.net (using VS2008, if
I'd like to add an own installation type into an Inno setup project, while
let me start by saying it may look simple but im finding it extremely
EDIT: This isn't as trivial as you think. Consider the fact that each addition

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.