Answer the question
In order to leave comments, you need to log in
Qt Python program hangs due to time.sleep(), how to fix?
Hello everyone, I am writing a client for Yandex Music on Unix using PyQt
I don’t have much experience with PyQt, and I don’t have experience with threads
So that’s the question, my program should pause at a certain moment, for this I use time.sleep()
class ExampleApp(QtWidgets.QMainWindow, design.Ui_MainWindow):
def __init__(self):
# Это здесь нужно для доступа к переменным, методам
# и т.д. в файле design.py
super().__init__()
self.setupUi(self) # Это нужно для инициализации нашего дизайна
print(1+1)
time.sleep(40) # И тут зависает намертво Qt до 40 секунд
Answer the question
In order to leave comments, you need to log in
Because you yourself set sleep. Any GUI program runs on the main thread, and you stop it for 40 seconds. Because of the stop, window messages are not processed, and this is the basis of the application's work with the GUI.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question