def populateDbxList(self): self.l_dbx.clear() l = dropbox_down.list_filenames('/') #fnames, isdir = zip(*l) for f in l: it = QtGui.QListWidgetItem(f[0][1::]) if f[1]: it.setIcon(QtGui.QIcon(r"dbx.ico")) else: it.setIcon(QtGui.QIcon(r"file.ico")) self.l_dbx.addItem(it) #self.l_dbx.addItem(f[1::]) #self.l_dbx.addItems(fnames) self.setProgressbarValue(self.progressBar_2, dropbox_down.get_space())
def dropEvent(self, e): if e.mimeData().hasText: e.setDropAction(QtCore.Qt.CopyAction) sysPath = e.mimeData().text()[7::] self.addItem(QtGui.QListWidgetItem(QtGui.QIcon(r'file.ico'), sysPath.split('/')[-1])) size = os.path.getsize(sysPath) dbxUsed, dbxTot = dropbox_down.get_space() drvUsed, drvTot = drive_down.get_space(drive_service) freeDbx = dbxTot - dbxUsed freeDrv = drvTot - drvUsed if size < freeDbx: dropbox_down.upload_file(sysPath, sysPath.split('/')[-1]) # l_dbx.popu() elif size < freeDrv: drive_down.upload_file(sysPath, drive_service) # l_drive.popu() else: pass #this line is not needed really #call upload function with e.mimeData().text() e.accept()