Create new thread to perform the progress:
http://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt
Try to keep a reference:
http://stackoverflow.com/questions/8359469/python-threading-thread-scopes-and-garbage-collection
Use single to update progress:
http://stackoverflow.com/questions/9682376/progress-bar-with-pyqt
Example: UploadThread:
class UploadTaskQtThread(QtCore.QThread): tick = QtCore.pyqtSignal(int, name="upload_changed") def __init__(self, client, local_path, remote_path): QtCore.QThread.__init__(self) self.client = client self.local_path = local_path self.remote_path = remote_path def on_progress(self, progress): self.tick.emit(progress * 100) def run(self): self.client.upload_file(self.local_path, self.remote_path, self.on_progress)
Client:
def upload(self, local_file_path, remote_path): self.upload_thread = UploadTaskQtThread(client, local_file_path, remote_path) self.upload_thread.start() self.upload_thread.tick.connect(ui.progressBar.setValue)
MacBook: How to replace hard drive and restore OS X from internet 苹果笔记本电脑更换硬盘并从网络安装系统 <->
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.