hier mein Ansatz:
Code: Alles auswählen
from PyQt5 import QtWidgets, uic, QtCore
import sys
import time
import shutil
import os
class UpdateCopy(QtCore.QThread):
update_progressbar = QtCore.pyqtSignal(int)
def __init__(self, destination_path=None,source_path=None):
QtCore.QThread.__init__(self)
self.destination_path=destination_path
self.source_path=source_path
def run(self):
while os.path.getsize(self.source_path) != os.path.getsize(self.destination_path):
val=int((float(os.path.getsize(self.destination_path))/float(os.path.getsize(self.source_path))) * 100)
time.sleep(.01)
self.update_progressbar.emit(val)
class Transfer_File(QtWidgets.QDialog):
def __init__(self):
super(Transfer_File,self).__init__()
uic.loadUi(Path(__file__).absolute().parent / "ui/Transfer.ui",self)
self.btn_OK.clicked.connect(self.updateThread)
def updateThread(self):
source_path=r"D:\\TMW.mp4"
destination_path=r"E:\\TMW.mp4"
self.lbl_Source.setText(source_path)
self.lbl_Desti.setText(destination_path)
self.prgBar_Transfer.setValue(0)
self.lbl_Done.setText("Datei übertragt: ")
self.copy=UpdateCopy(destination_path,source_path)
self.copy.start()
shutil.move(source_path, destination_path)
self.copy.finished.connect(self.evt_update_copy_finnished)
self.copy.update_progressbar.connect(self.evt_update_progress)
def evt_update_copy_finnished(self):
self.lbl_Done.setText("Fertig!")
self.prgBar_Transfer.setValue(100)
def evt_update_progress(self,val):
self.prgBar_Transfer.setValue(val)
if __name__ == '__main__':
app =QtWidgets.QApplication(sys.argv)
Transfer_File=Transfer_File()
Transfer_File.show()
sys.exit(app.exec_())
2. wenn ich auf OK klicke führt er aus meiner Sicht nur das aus:
Code: Alles auswählen
self.lbl_Source.setText(source_path)
self.lbl_Desti.setText(destination_path)
self.prgBar_Transfer.setValue(0)
self.lbl_Done.setText("Datei übertragt: ")
self.copy=UpdateCopy(destination_path,source_path)
Ich hab einige Videos (morpheus oder https://www.youtube.com/watch?v=G7ffF0U36b0&t=6s) angeschaut, aber nichts passt zu meins. Ich finds schwer zu kapieren, evtl hilft mir da einer und bitte nicht mit irgendeinen Fachchinesisch. Das hilft keinen.