PyQt file copy progress bar -


I am trying to get a QProgressBar to show the progress of a file copy in PyQt. I've seen and I've got to run the actual copy in QFile using a formula. I just can not get the bar to update though.

Here are some code:

  class ProgressDialog (QtGui.QDialog): def __init __ (self, guardian, source, destination): QtGui.QDialog .__ init __ (Self, guardian) Self.parent = Parents themselves Source = source self.estination = destination self.add_diag = progress_diag.Ui_Dialog () self.add_diag.setupUi (self) self.add_diag.infoLabel.setText ("copy:% s"% (self) .source) self.sourcefile = QtCore.QFile (self.source) self.add_diag.progressbar.set Minimal (0) self.add_diag.progressbar.setMaximum (self.sourcefile.size () / 1024) self.written = 0self.show () self. Copy (): Copy_thread = CopyThread (self, self.sourcefile, self.estination) self.connect (copy_thread.destination_file, QtCore.SIGNAL ("bytes written (qint64)"), auto.update_progress) copy_thread. ProcDone.connect (self.finished_copy) copy_thread.start () def update_progress (auto, progress): print "task", progress self.written + = progress self.add_diag.progressB Ar.setValue (written / 1024) def finish_copy (self, state): self. Close () CL ass CopyThread (QtCore.QThread): procDone = QtCore.pyqtSignal (bool) def __init __ (self, parent, source, destination): QtCore.QThread .__ init __ (self, parent) self.source = Source self.destination_file = QtCore.QFile (destination) run DEF (self): self.source.copy (self.destination_file.fileName ()) self.procDone.emit (true)   

Update_progess is said to be ever so that such a sign is not clearly emitted, but I'm not sure why.

I have searched this high and low on this, but have not found a good PyQt solution for this so that any help is great.

itemprop = "text">

QFile bytesWritten not emitted:

The form of such QTcpSocket In contrast to other QIODevice implementations, aboutToClose () about QFile does not emit the written (), or readyRead () signals. This implementation expansion means that QFile is readable and is not suitable for writing specific types of files, such as device files on Unix platforms.

You must apply your own loop and progress emerges from yourself.

Comments