Hello. As from the topic title, i am trying to work a multithread GUI where the progress bar indicates the running process completion (like we always see when we are installing/uninstalling/downloading). I've read a couple of written tutorials and some other forums discussions regarding the progress bar and multithreading. I've also even tried the simple multithreading examples given but I still don't get it especially adding the process that i want to run.
This is my GUI (simple) :
class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.progressBar.setVisible(False) #I WASN'T SUCCESSFULL IN MANUALLY CREATING A PROGRESS BAR BUT THATS ANOTHER ISSUE ILL DEAL WITH LATER
self.btn_browse.clicked.connect(self.OpenFile)
self.btn_hash.clicked.connect(self.CalcHash)
def OpenFile(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileName, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","Raw Files (*.dng)", options=options)
if fileName:
self.txt_filename.setText(fileName)
def CalcHash(self):
self.progressBar.setVisible(True)
##THE PROCESS
##THE PROCESS IS SUPPOSE TO BE HERE RIGHT??
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MyApp()
window.show()
sys.exit(app.exec_())
so then i need a "worker" class (the new thread), where the progress bar (so far all the example says that) process will be run.
class TheThread(QThread):
#signals to communicate to the main program class
countChanged = pyqtSignal(int)
def run(self):
count = 0
while count < TIME_LIMIT:
count +=15
time.sleep(1)
self.countChanged.emit(count)
i need something like this in my CalcHash func:
self.worker = TheThread()
self.worker.updateProgress.connect(self.onProgress)
self.worker.start()
But the progress bar doesn't "progress" just blank while my calc hash runs. Please help. Thank you in advance.