Hello community,
A while ago I sent a question about a problem with QMessageBox and message bar
does not get updated during a long process.
In my example I create a script like this.
from qgis.PyQt import QtWidgets
message = "Wait to open the airspace project..."
msg = QtWidgets.QMessageBox()
msg.setText(message)
msg.show()
qgis.utils.iface.messageBar().pushMessage("Wait", message)
for i in range(1000):
print(i)
qgis.utils.iface.messageBar().pushMessage("Done", "The process is done")
msg.setText("The process is done")
msg.show()
qgis.utils.iface.messageBar().pushMessage("Done", "The process is done"))
When I run the scrip in QGIS 2.18 the QMessageBox displays first the message
"Wait to open the airspace project...". The same message is pushed to
messageBar.
Then during the loop it displays the variable i.
At the end of the loop the QMessageBox displays the message "The process is
done" which is also pushed to the messageBar.
When I run the same scrip on QGIS 3 the QMessageBox is empty. The message "Wait
to open the airspace project..." is not displayed by QMessageBox nor by
messageBar.
The print inside the loop displays the I and when the loop is done the
QMessageBox displays the message "The process is done".
The messageBar displays also the message "The process is done". And after a
while it displays the initial message "Wait to open the airspace project..."
I modified the scrip by adding QApplication.processEvents() inside the loop and
now everything is fine.
It seems QGIS3 no longer triggers this event loop and I have to do this
explicitly by calling processEvents from QApplication.
Why QGIS 3 needs to call QApplication.processEvents() and QGIS 2 does not need?
Thank you,
Marian
________________________________
This electronic message, as well as any transmitted files included in the
electronic message, may contain privileged or confidential information and is
intended solely for the use of the individual(s) or entity to which it is
addressed. If you have received this electronic message in error please notify
the sender immediately and delete the electronic message. Any unauthorized
copying, disclosure or distribution of the electronic message is strictly
forbidden. NAV CANADA accepts no liability for any damage caused by any virus
and/or other malicious code transmitted by this electronic communication.
Le pr?sent message ?lectronique et tout fichier qui peut y ?tre joint peuvent
contenir des renseignements privil?gi?s ou confidentiels destin?s ? l'usage
exclusif des personnes ou des organismes ? qui ils s'adressent. Si vous avez
re?u ce message ?lectronique par erreur, veuillez en informer l'exp?diteur
imm?diatement et supprimez le. Toute reproduction, divulgation ou distribution
du pr?sent message ?lectronique est strictement interdite. NAV CANADA n'assume
aucune responsabilit? en cas de dommage caus? par tout virus ou autre programme
malveillant transmis par ce message ?lectronique.
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user