-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (53 loc) · 2.91 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
69
70
71
72
73
74
75
import customtkinter
from components.checkboxframe import ScrollableCheckboxFrame
from components.radiobuttonframe import RadiobuttonFrame
from components.processingframe import ProcessingFrame
from disk import get_drives
from recover import RecoverFiles
from multiprocessing import Process, cpu_count
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.destinationPath: str = "C:/recovered-files"
file_extensions = [ "JPG", "PNG", "PDF" ]
self.process = None
self.processing_frame: customtkinter.CTkFrame | None = None
self.title("FrankensFile")
self.geometry("400x300")
self.grid_columnconfigure((0, 1), weight=1)
self.grid_rowconfigure(0, weight=1)
self.radiobutton_frame = RadiobuttonFrame(self, "Drives", values=get_drives())
self.radiobutton_frame.grid(row=0, column=0, padx=(10, 0), pady=(10, 0), sticky="nsew")
self.checkbox_frame = ScrollableCheckboxFrame(self, "File Types", values=file_extensions)
self.checkbox_frame.grid(row=0, column=1, padx=10, pady=(10, 0), sticky="nsew")
self.destPath = customtkinter.CTkLabel(self, text=self.destinationPath, fg_color="gray30", corner_radius=6)
self.destPath.grid(row=3, column=0, padx=10, pady=(10, 0), sticky="w", columnspan=2)
self.button = customtkinter.CTkButton(self, text="Choose the destination path for the files.", fg_color="#062f4f", command=self.open_file_explorer)
self.button.grid(row=4, column=0, padx=10, pady=(10, 0), sticky="ew", columnspan=2)
self.button = customtkinter.CTkButton(self, text="START", fg_color="#010057", command=self.button_callback)
self.button.grid(row=5, column=0, padx=10, pady=10, sticky="ew", columnspan=2)
def open_file_explorer(self):
# Open the file explorer dialog and store the selected path
path: str = customtkinter.filedialog.askdirectory()
if path.lower() == 'c:/' or path.lower() == '':
path = f'{path}/recovered-files'
self.destPath.configure(text=path)
self.destinationPath = path
def button_callback(self):
drive = self.radiobutton_frame.get()
file_exts = self.checkbox_frame.get()
print(f"Drives: -> {drive}")
print(f"File Extensions: -> {file_exts}")
print(f"Recovery Destination Path: -> {self.destinationPath}")
self.processing_frame = ProcessingFrame(self, "Processing...", self.stop)
self.processing_frame.grid(row=0, column=0, padx=10, pady=10, sticky="nsew", columnspan=2, rowspan=7)
self.update()
self.process = Process(target=RecoverFiles, args=(drive, file_exts, self.destinationPath))
self.process.start()
def stop(self):
print('stop')
self.process.terminate()
self.processing_frame.destroy()
if __name__ == "__main__":
app = App()
app.mainloop()