Reputation: 2842
im new in python and i have created an uploading program with multi threading, my problem is i have only one progress bar that displays the progress of each thread. im using python pyqt4 QThread. Is there a way to know whats the progress of each uploading thread? here are some parts of the code.
class Worker(QThread):
def __init__(self,parent=None):
QThread.__init__(self,parent)
self.counter = 0
self.received = 0
self.size = 0
self.f = None
self.ftp = None
self.filename = ""
def __del__(self):
self.wait()
def handleDownload(self, block):
self.counter += 1
self.received += len(block)
the handleDownload() will then emit signal to the progress bar to update its value.
thx
Upvotes: 1
Views: 407
Reputation: 2568
You need to create a counter object that's shared between all threads. Each time a thread completes a download it locks with a QMutex increments the count and unlocks you can then send your signal and modify the progress bar(although you may want to make sure it doesn't update too often)
Upvotes: 2