-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.py
More file actions
231 lines (179 loc) · 9.74 KB
/
Copy pathobject.py
File metadata and controls
231 lines (179 loc) · 9.74 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import customtkinter
import tkinter
import time
import threading
import os
def convert(size):
data_type = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " YB"]
i=0
while len(str(size).split(".")[0])>3:
size = size/1024
i+=1
return str(round(size,2))+data_type[i]
def pass_():
pass
def pass_e(e):
pass
def get_saved_paths():
paths = []
for path in open("settings\\paths", "r"):
paths.append(path.replace("\n",""))
return paths
def save_paths(custom_paths):
f = open("settings\\paths", "w")
f.write("\n".join(custom_paths[6:]))
f.close()
class scrollableFrame(customtkinter.CTkFrame):
def __init__(self, master ,fg_color ,**kwargs):
super().__init__(master,fg_color=fg_color,**kwargs)
self.master = master
self.mainCanvas = tkinter.Canvas(master=self ,
bg=fg_color ,
scrollregion=(0,0,0,0) ,
highlightthickness=0)
self.verticalScroller = customtkinter.CTkScrollbar(master=self ,
command=self.mainCanvas.yview ,
orientation='vertical' ,
fg_color=fg_color ,bg_color=fg_color)
self.verticalScroller.place(relheight=1 ,relx=1 ,x=-13 ,width=15)
#maincanvas sync with scrollabars
self.mainCanvas.configure(yscrollcommand=self.verticalScroller.set)
#create top frame for all widget
self.outputFrame = customtkinter.CTkFrame(master=self.mainCanvas ,
fg_color=fg_color ,bg_color="#090909")
self.mainCanvas.create_window((0,0) ,window=self.outputFrame,anchor='nw')
self.mainCanvas.place(relwidth=1 ,relheight=1 ,width=-25)
#self.masterFrame.bind('<Configure>' ,self.__configure)
self.configureWinfo(height=self.mainCanvas.winfo_height())
def configureWinfo(self,width=None,height=None):
if width==None:
width = self.mainCanvas.winfo_width()
if height==None:
height = self.outputFrame.winfo_height()
self.mainCanvas.configure(scrollregion=(0,0,width,height))
self.mainCanvas.configure(height=height, width=width)
self.outputFrame.configure(width=width, height=height)
class scannedFileInfoFrame(customtkinter.CTkFrame):
def __init__(self, master=None, fg_color=None):
super().__init__(master=master, fg_color=fg_color, border_width=1)
self.directory_name = customtkinter.CTkLabel(master=self , text="", text_color="#ffffff", text_font=("arial", 10, "bold"), height=16, fg_color="#090909", width=1)
self.directory_name.place(x=2, y=1)
self.file_count_total_size = customtkinter.CTkLabel(master=self, text="0 B", height=16, width=1, text_font=("arial", 10, "bold"))
self.file_count_total_size.place(relx=1, x=-150, y=1)
self.scrollbar = customtkinter.CTkScrollbar(master=self, fg_color="#090909")
self.scrollbar.place(relx=1, x=-20, relheight=1, height=-3, y=1)
self.file_names = tkinter.Listbox(master=self ,yscrollcommand=self.set_scrollbar, bg="#090909", fg="#ffffff", highlightthickness=0, bd=0 ,font=("arial",9,"bold"))
self.file_names.place(y=17, x=30, relwidth=1, relheight=1, height=-19, width=-150 )
self.file_sizes = tkinter.Listbox(master=self ,yscrollcommand=self.set_scrollbar , bg="#090909", fg="#ffffff", highlightthickness=0, bd=0 ,font=("arial",9,"bold"))
self.file_sizes.place(y=17 ,relx=1, x=-100, width=70, relheight=1 ,height=-19)
self.scrollbar.configure(command=self.scroll)
def scroll(self,*args):
self.file_names.yview(*args)
self.file_sizes.yview(*args)
def set_scrollbar(self,*args):
self.scrollbar.set(*args)
self.file_names.yview("moveto",args[0])
self.file_sizes.yview("moveto",args[0])
pass
class scanButton(customtkinter.CTkButton):
def __init__(self, master=None, command=None):
super().__init__(master=master, width=225, height=225, hover_color=None, text="", fg_color=None, command=command)
self.scan_button_images_path = ["src/scan button/0"+str(num)+".png" for num in range(1,10)]
self.scan_button_react_images_path = ["src/scan button react/0"+str(num)+".png" for num in range(1,10)]
self.scan_button_images = [tkinter.PhotoImage(file=file) for file in self.scan_button_images_path]
self.scan_button_images_react = [tkinter.PhotoImage(file=file) for file in self.scan_button_react_images_path]
self.progress_label = tkinter.Label(master=master, text="100%" ,font=("arial", 11, "bold") ,bg="#151515", fg="#ffffff")
self.scan_initializing_button_images_path = ["src/scan Initializing button/"+str(num)+".png" for num in range(0,5)]
self.scan_initializing_button_images = [tkinter.PhotoImage(file=file) for file in self.scan_initializing_button_images_path]
self.scan_stop_button_images_path = ["src/stop button/"+str(num)+".png" for num in range(0,41)]
self.scan_stop_button_images = [tkinter.PhotoImage(file=file) for file in self.scan_stop_button_images_path]
self.scan_cleaning_button_images_path = ["src/scan cleaning button/"+str(num)+".png" for num in range(0,41)]
self.scan_cleaning_button_images = [tkinter.PhotoImage(file=file) for file in self.scan_cleaning_button_images_path]
self.scan_clean_button_images_path = ["src/scan clean button/"+str(num)+".png" for num in range(0,1)]
self.scan_clean_button_images = [tkinter.PhotoImage(file=file) for file in self.scan_clean_button_images_path]
def react(self,e):
self.Entered = True
def react_():
for self.image_index in range(self.image_index, 9):
if self.Entered==False :
break
self.configure(image=self.scan_button_images_react[self.image_index])
time.sleep(0.01)
threading.Thread(target=react_).start()
def react_back(self,e):
self.Entered = False
def react_back_():
for self.image_index in range(self.image_index, -1, -1):
if self.Entered==True :
break
self.configure(image=self.scan_button_images[self.image_index])
time.sleep(0.01)
threading.Thread(target=react_back_).start()
def set_normal(self):
self.initializing = False
self.initializing_success = False
self.scanning = False
self.scanning_success = False
self.progress_label.place_forget()
self.set_progress("scanning",0)
self.image_index = 0
self.Entered = False
self.configure(image=self.scan_button_images[0])
self.bind("<Enter>", self.react)
self.bind("<Leave>", self.react_back)
self.configure(image=self.scan_button_images[0])
self.bind("<Enter>", self.react)
self.bind("<Leave>", self.react_back)
def set_initializing(self):
self.bind("<Enter>", pass_e)
self.bind("<Leave>", pass_e)
self.initializing = True
self.initializing_success = False
def reading():
i = 0
while self.initializing:
self.configure(image=self.scan_initializing_button_images[i])
i +=1
if i>4:
i=0
time.sleep(0.2)
self.initializing_success = True
threading.Thread(target=reading).start()
def set_scanning(self):
self.bind("<Enter>",pass_e)
self.bind("<Leave>",pass_e)
self.progress_label.place(relx=0.5, y=155, anchor="center")
def set_clean(self):
self.progress_label.configure(text="")
self.configure(image=self.scan_clean_button_images[0])
def set_progress(self, type, progress):
if progress>100:
progress = 100
progress = round(progress, 2)
dec = str(progress).split(".")[-1]
dec = "." + dec + ((2-len(dec))*"0")
if type == "scanning":
self.configure(image=self.scan_stop_button_images[int(40/100*progress)])
if type == "cleaning":
self.configure(image=self.scan_cleaning_button_images[int(40/100*progress)])
self.progress_label.configure(text= str(int(progress))+dec +"%")
def configure(self,**kwarg):
super().configure(**kwarg)
class fileDirectory(customtkinter.CTkFrame):
def __init__(self, master=None, directory=None, height=None, fg_color=None, directories=[]):
super().__init__(master=master.outputFrame, height=height, fg_color=fg_color)
customtkinter.CTkLabel(master=self, text=directory, text_font=("arial", 9, "bold"), anchor="w").place(x=1)
self.remove_btn = customtkinter.CTkButton(master=self, text="X", command=self.remove, text_font=("arial", 7, "bold"))
self.remove_btn.place(relx=1, x=-40, width=22, height=22, y=2)
self.directory = directory
self.directories = directories
self.master = master
self.master.configureWinfo(height=27*len(self.directories))
self.line = tkinter.Frame(master=master.outputFrame, height=1 ,bg="#151515")
def remove(self):
self.line.pack_forget()
self.pack_forget()
self.directories.remove(self.directory)
self.master.configureWinfo(height=27*len(self.directories))
save_paths(self.directories)
del self