-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.pyw
71 lines (51 loc) · 2.83 KB
/
main.pyw
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
import tkinter as tk, subprocess, shutil, util, separator_wizard, customize_shortcut, open_source_licenses, change_language, change_theme, strings, custom_ui
from tkinter import ttk, filedialog
window = custom_ui.App()
window.title("Files & Folders on Taskbar")
window.resizable(False, False)
window.iconbitmap(util.internal + "icon.ico")
window.configure(padx = 14, pady = 8)
shortcut_type = tk.StringVar(value = "file")
subprocess.call(f"rmdir /q /s \"{util.working_folder}\\separators\"", shell = True)
shutil.copytree(util.internal + "separators", util.working_folder + "\\separators")
def browse(shortcut_type):
if shortcut_type == "file":
file = filedialog.askopenfile(title = strings.lang.choose_a_file, parent = window)
if not file.name == "": customize_shortcut.show("file", file.name)
else: return
else:
folder = filedialog.askdirectory(title = strings.lang.choose_a_folder, parent = window).replace("\"", "")
if not folder == "": customize_shortcut.show("folder", folder)
else: return
def destroy_everything(widget):
for child in widget.winfo_children():
child.destroy()
def change_app_language():
old_language = util.language
change_language.show()
window.wait_window(change_language.window)
if old_language != util.language: draw_ui()
def change_app_theme():
old_theme = util.theme
change_theme.show()
window.wait_window(change_theme.window)
if old_theme != util.theme:
custom_ui.update_colors()
window.set_theme()
draw_ui()
def draw_ui():
destroy_everything(window)
strings.load_language(open(util.user_preferences + "\\language", "r").read())
ttk.Label(window, text = "Files & Folders on Taskbar", font = ("Segoe UI Semibold", 17)).pack(anchor = "w")
ttk.Label(window, text = strings.lang.pin_to_taskbar_a_shortcut_to).pack(anchor = "w", pady = (4, 8))
custom_ui.CommandLink(window, text = strings.lang.a_file, command = lambda: browse("file")).pack(fill = "x", expand = True)
custom_ui.CommandLink(window, text = strings.lang.a_folder, command = lambda: browse("folder")).pack(fill = "x", expand = True)
custom_ui.CommandLink(window, text = strings.lang.a_separator, command = separator_wizard.show).pack(fill = "x", expand = True)
ttk.Label(window, text = strings.lang.settings, font = ("Segoe UI Semibold", 14)).pack(anchor = "w", pady = (16, 4))
custom_ui.Toolbutton(window, text = strings.lang.change_language, command = change_app_language).pack(anchor = "w")
custom_ui.Toolbutton(window, text = strings.lang.change_theme, command = change_app_theme).pack(anchor = "w")
custom_ui.Toolbutton(window, text = strings.lang.see_open_source_licenses, command = open_source_licenses.show).pack(anchor = "w")
window.update()
draw_ui()
custom_ui.sync_colors_with_system(window)
window.mainloop()