-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
68 lines (53 loc) · 1.69 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import sys
from tkinter import *
from tkinter import filedialog
from ImageFile import ImageFile
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QMainWindow, QApplication
from SorterWindow import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.src_path = ""
self.dst_path = ""
@Slot()
def src_dir_slot(self):
root = Tk()
root.withdraw()
self.src_path = filedialog.askdirectory()
self.ui.lb_src_dir.setText(self.src_path)
@Slot()
def dst_dir_slot(self):
root = Tk()
root.withdraw()
self.dst_path = filedialog.askdirectory()
self.ui.lb_dst_dir.setText(self.dst_path)
@Slot()
def go_slot(self):
image_files = []
self.ui.lb_total_number.setText(f"{len(self.get_src_files())}")
for file in self.get_src_files():
path = f"{self.src_path}/{file}"
image_files.append(ImageFile(path))
QApplication.processEvents()
cont = 0
for image_file in image_files:
image_file.move_file(self.dst_path)
cont += 1
value = int((cont / len(image_files)) * 100)
self.ui.progressBar.setValue(value)
self.ui.lb_current_number.setText(f"{cont}")
QApplication.processEvents()
@Slot()
def progress_changed_slot(self):
pass
def get_src_files(self):
return os.listdir(self.src_path)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())