I have a program that graphs data using an embedded matplotlib plot and adds helpful visualizations. The problem is matplotlib can be very slow when these visualizations are heavy, to the point where the main window hangs. I can't add these graphics in a different thread or process because PyQt forbids updating the main window from anywhere but the main thread (for good reason), so instead I would like to have another window with basically a perpetual progress bar that I can kill when the graphing is done:
# Creates a new window with an endless progress bar
main_widget = QtGui.QWidget(self)
layout = QtGui.QVBoxLayout()
layout.addWidget(QtGui.QLabel("Graphing now. Please wait...", self))
progress = QtGui.QProgressBar(self)
I figured out my problem. It's not a total fix but I had to go back through to where the visualizations are being added and periodically call this function:
This let my UI update every once in a while so that the window at least didn't hang. I also thought it best to disable the main window so that the user can't mess things up while the graphs are being generated, and I added the Loading Window from my original post so that the user knows whats happening.