diff --git a/main.py b/main.py index cbd01ec..ba7555f 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ from PyQt6.QtWidgets import QApplication from wmain import wMain -version = "20231018" +version = "20231019" if __name__ == "__main__": app = QApplication([]) diff --git a/warchive.py b/warchive.py index 8f3b3b7..496cbf2 100644 --- a/warchive.py +++ b/warchive.py @@ -12,7 +12,6 @@ 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): @@ -187,46 +186,56 @@ class wArchive(QDialog): self.bArchive.setEnabled(True) def copyDataThread(self): - self.copyDataThread = threading.Thread(target=self.copyData) + threads = [] + self.copyDataThread = threading.Thread(target=copyData, args=(self, + self.bArchive, + self.progressBar, + self.files, + self.ArchivePath, + self.pName, + self.pBirth,)) + threads.append(self.copyDataThread) self.copyDataThread.start() - self.copyDataThread.join() - # Close wArchive - self.close() +class copyData(): + def __init__(self, warchive, barchive, progressbar, files, archivepath, pname, pbirth): + self.warchive = warchive + self.barchive = barchive + self.progressbar = progressbar + self.files = files + self.archivepath = archivepath + self.pname = pname + self.pbirth = pbirth - def copyData(self): + self.barchive.setEnabled(False) - self.bArchive.setEnabled(False) - - source = self.files - - # LastName^FirstName^Birth - mainFolder = os.path.join(self.ArchivePath, self.pName + "^" + self.pBirth) + mainFolder = os.path.join(self.archivepath, self.pname + "^" + self.pbirth) try: os.mkdir(mainFolder) except: pass - - # LastName^FirstName^Birth\1234 - subFolder = self.randomString(4) + + subFolder = randomString(4) os.mkdir(os.path.join(mainFolder, subFolder)) filename = 1 - for file in source: + for file in self.files: shutil.copy(file, os.path.join(mainFolder, subFolder, str(filename))) - self.progressBar.setValue(int(filename / len(self.files) * 100)) + 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) - @staticmethod - def randomString(length): - string = "" - chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" - - for _ in range(length): - char = random.choice(chars) - string = string + char - - return string + self.barchive.setEnabled(True) + self.warchive.hide() + +@staticmethod +def randomString(length): + string = "" + chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" + + for _ in range(length): + char = random.choice(chars) + string = string + char + + return string