From dc1d46c8cafc41fb3276fc384c680eeeb7463d00 Mon Sep 17 00:00:00 2001 From: gideonstar Date: Wed, 18 Oct 2023 10:52:37 +0200 Subject: [PATCH] =?UTF-8?q?ProgressBar=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- warchive.py | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 1774d35..cbd01ec 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ from PyQt6.QtWidgets import QApplication from wmain import wMain -version = "20231017" +version = "20231018" if __name__ == "__main__": app = QApplication([]) diff --git a/warchive.py b/warchive.py index c2ddb86..8f3b3b7 100644 --- a/warchive.py +++ b/warchive.py @@ -11,6 +11,8 @@ from PyQt6.QtWidgets import QDialog from PyQt6.QtWidgets import QLabel from PyQt6.QtWidgets import QPushButton from PyQt6.QtWidgets import QStyle +from PyQt6.QtWidgets import QProgressBar +from PyQt6.QtCore import QThread class wArchive(QDialog): @@ -82,7 +84,10 @@ class wArchive(QDialog): self.bArchive = QPushButton("Archivieren", self) self.bArchive.setGeometry(10, 350, 380, 40) self.bArchive.setEnabled(False) - self.bArchive.clicked.connect(self.copyData) + self.bArchive.clicked.connect(self.copyDataThread) + + self.progressBar = QProgressBar(self) + self.progressBar.setGeometry(10, 320, 380, 20) archive = threading.Thread(target=self.archive) archive.start() @@ -176,12 +181,21 @@ class wArchive(QDialog): # Output file count self.tLine10.setText(str(len(self.files))) - - # Activate bArchive + + # Activate bArchive and show progress bar if dicomfile and dicomdir and target_writable and has_dicom_files and has_pBirth and has_pName: self.bArchive.setEnabled(True) + def copyDataThread(self): + self.copyDataThread = threading.Thread(target=self.copyData) + self.copyDataThread.start() + self.copyDataThread.join() + + # Close wArchive + self.close() + def copyData(self): + self.bArchive.setEnabled(False) source = self.files @@ -200,13 +214,12 @@ class wArchive(QDialog): filename = 1 for file in source: shutil.copy(file, os.path.join(mainFolder, subFolder, str(filename))) + self.progressBar.setValue(int(filename / len(self.files) * 100)) filename += 1 # Eject CD ctypes.windll.WINMM.mciSendStringW(u"set cdaudio door open", None, 0, None) - self.close() - @staticmethod def randomString(length): string = ""