QMessageBox black out

100 Views Asked by At

I have a pyqgis script done in QGIS 2.18 which basically open a QGIS3 project with around 9 layers.

There is a lag until these layer are displayed on the canvas so I put a QMessageBox to display a waiting message for the user.

This is the script:

#start the script
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")

When I run the script as is in QGIS 2.18 the message "Wait to open the airspace project..." is displayed on both message bar and QMessageBox. Then the loop starts and it display the i. And at the end the message "The process is done" is displayed in both message bar and QMessageBox.

If I run the same scrip in 3.22.8-Białowieża, the loop starts and no wait message is displayed. The QMessageBox is somehow displayed without any message. After the loop is done "The process is done" is displayed in both pushed bar and QMessageBox. What is strange "The process is done" disappear from the pushed bar and "Wait to open the airspace project..." is displayed. So this behavior is useless for the user. Is anyway hot to make QGIS 3.22 to display these messages in the proper sequence as they used to be displayed in QGIS 2.18.

I hope you can access the video at this link. I explained the behavior and you can see it

0

There are 0 best solutions below