Answer the question
In order to leave comments, you need to log in
Hangs gui (pyqt5) when executing while / time.sleep. What to do?
When you click on the button, you need to execute the required number of queries in the while loop, here is the code (the block of code itself, which is executed when the button is clicked):
# Начало залива
def startJob(self):
# Логи
self.addLog('Сохраняем настройки...')
# Настройки и переменные
self.isJobStopped = False # Начинаем работу
incr = 1 # Счетчик
while incr <= self.spinBox.value(): # Начинаем выполнять запросы
if self.isJobStopped == False:
send_request = requests.post('https://youtube.com/example')
self.addLog('Выполнено запросов: ' + str(incr) + '/' + str(self.spinBox.value()))
incr += 1
else:
break
self.addLog('Работа окончена.')
Answer the question
In order to leave comments, you need to log in
The problem seems to be solved. With grief on the floor, I created a separate thread of the QThread object, in which, at startup, all actions were performed and signals were sent to the slot in the UI thread, where they were already processed. The topic can be considered closed.
Ps this topic helped here https://nikolak.com/pyqt-threading-tutorial/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question