self.dialogBox.close()
self.state = "processing"
self.__clearLayout(self.layout)
print(1)
self.controller.process()
I am running the following code. The dialog box is a PyQt dialog box, self.state
is just a current state, self.__clearLayout
clears the current layout of the PyQt widget, print(1)
is there for debugging purposes, and self.controller.process()
is what processes things and it takes a while. My goal is to clear the UI and then have my program process, but it is out of order. It prints 1
and begins processing, which is telling me that it is in order but the UI isn't setting until after the process is done. Any tips on how to fix this?
def processUi(self):
self.dialogBox.close()
self.state = "processing"
self.__clearLayout(self.layout)
#label
processingLabel = QtWidgets.QLabel()
processingLabel.setMaximumSize(500, 500)
processingLabel.setFont(QtGui.QFont("Mono", 16))
processingLabel.setText("Processing...may take a few minutes.")
#set the current layout
currentLayout = QtWidgets.QVBoxLayout()
currentLayout.setContentsMargins(0,0,0,0)
currentLayout.addStretch()
currentLayout.addWidget(processingLabel)
currentLayout.addStretch()
self.layout.addStretch()
self.layout.addLayout(currentLayout)
self.layout.addStretch()
#thread for processing
processing = multiprocessing.Process(target=self.controller.process, args=())
processing.start()
processing.join()
self.finishedUi()
This is the full code. The goal is to set the ui code you see while the processing is working and once the process finishes, to call finishedUi.