Reputation: 742
I have this code running on a PyQt window on windows:
try:
self.actorUser.findIdfFiles(pathToFolder)
msg = "Processando arquivos..."
self.processingLabel.setText(msg)
self.actorUser.runSimulation(pathToFolder, pathToEpw)
Inside the "runSimulation" code I start a subprocess using the method "call". This blocks my GUI and at the title of the window appears "Python stopping responding", but if I wait a little bit the subprocess finishes normally, and the label is finally changed. But what I want is that the label have is text really changed before the subprocess started. What can I do??
Upvotes: 0
Views: 1415
Reputation: 11
Joe P 's answer is quite right. But this method is change to
QtCore.QCoreApplication.processEvents()
in pyqt5
link: https://doc.qt.io/qt-5/qcoreapplication.html#processEvents
Upvotes: 1
Reputation: 485
Qt (and most UI frameworks) don't update the display as soon as values are set, only when they are told to repaint.
What you need to do is add a call
QtGui.QApplication.processEvents()
before your long-running subprocess, to make it process all pending events.
Upvotes: 3