Python Forum
PyQt GUI not responding
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt GUI not responding
#1
Hello i made simple code like this with PyQt5. While my function is counting my GUI is not responding.

Please can somebody show me how to change this code to get it work with that "Threads" thing ?

Also i noticed this same issue happens to me when i use time.sleep( ). While my program is "sleeping" my QUI is not responding. What i am missing guys ?

THANK YOU !

import sys
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import *



class Window(QMainWindow):

   def __init__(self):
       super().__init__()

       self.setFixedSize(300, 300)
       self.move(100,100)
       self.setWindowTitle("Hello")

       self.label = QLabel(self)
       self.label.setText("Not done")
       self.label.resize(400,500)
       self.label.move(0,5)


       self.b1 = QtWidgets.QPushButton(self)
       self.b1.setText("Count")
       self.b1.move(100, 120)
       self.b1.resize(130, 32)
       self.b1.clicked.connect(self.Count)

       self.show()

   def Count(self):
       self.i = 0

       while self.i != 50000000:
              self.i +=1

       self.label.setText("DONE")





if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()
    sys.exit(app.exec())
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multi windows in tkinter buttons not responding correctly curtjohn86 13 11,585 Jul-01-2017, 03:42 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020