Reputation: 645
I have some operations that take place in the init() phase of my GUI. It looks for the presence of a file in a particular location and if it finds it, it will pop up a message box asking the user if they want to load the settings in that file. When I place that operation in the init() phase, the pop up comes up first and the GUI is not present at all. If I move that function to a button on demand, outside of init(), then it works fine. The GUI comes up, I click my button and the message box appears, etc. My understanding is that it's very difficult to interact with the GUI from threads outside the main thread, but because the message box comes up and the GUI does not load behind it, I'm assuming the message box is blocking. I have found in my online research folks saying that it's NOT blocking, but the behavior of having this message box coming up without the rest of the GUI loading behind it would say otherwise. This makes me think I need to make the message box non-blocking, but I don't know how to do that other than launching the message box in another thread, which again may not be possible since you need to be in the main thread to do so? I've read about differences regarding how the QMessageBox is constructed, .show() vs. ._exec(), etc. but not sure that will fix the issue? If you want to see my init() or a screenshot of the behavior I can upload that.
Below is the code I'm using to launch the message box:
def popUpYN(self, message):
if QMessageBox.StandardButton.Yes == QMessageBox.question(
self,
'',
message,
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
):
return True
else:
return False
# // END popUpYN()
Upvotes: 0
Views: 84