python - PyQt Not updating label -
i've created simple application transfer files using paramiko , sftp. wanted have statusbar (a qlabel) inform user when i'm downloading/uploading stuff. so, function upload looks this:
def upload(self): self.statuslabel.settext('uploading') local = str(self.uploadlineedit.text()) filename = os.path.basename(local) remote = "/home/" + self.username + "/testdata/" + filename self.ftp.put(local, remote) self.uploadedfilename = filename self.statuslabel.settext('upload finished')
notice before starting upload change statusbar uploading, , when upload done, change upload finished.
however, happens "uploading" message never displayed on label - goes straight "upload finished". suspect because changes happen after function returns.
how label change @ start of upload process?
you might need force processing of events after changing label text. try adding:
qapplication.processevents()
after setting label text.
please note reason not known me, pyqt , pyside both tend have problems processevents
, needs executed multiple times take effect. so, if not work after adding single processevents()
, try adding twice, or multiple times.
Comments
Post a Comment