-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDesky.pyw
312 lines (234 loc) · 9.26 KB
/
Desky.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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
import customtkinter as CTk
import json
from tkinter import *
import subprocess
import requests
import webbrowser
from tkinter import messagebox
import sys
import os
import time
file_path = None
language = None
log_folder = "errors_logged"
log_prefix = "errors_log_from_.txt"
if not os.path.exists(log_folder):
os.makedirs(log_folder)
current_time = time.strftime("%m%d%Y-%H-%M-%S")
log_file = log_prefix + current_time + ".txt"
log_path = os.path.join(log_folder, log_file)
sys.stderr = open(log_path, "a")
def update_username():
global change_username_entry
change_username_entry = CTk.CTkEntry(app, width=230)
change_username_entry.focus()
change_username_entry.place(x=10, y=50)
global update_password_button
update_password_button = CTk.CTkButton(
app, text="\u2714", width=5, font=("Arial", 20), command=save_username)
update_password_button.place(x=250, y=50)
global cancel_change_button
cancel_change_button = CTk.CTkButton(app, width=5, text="\u274C", font=(
"Arial", 20), command=cancel_username_changes)
cancel_change_button.place(x=290, y=50)
def save_username():
global username
username = change_username_entry.get()
with open("src/user_settings.json", "r+") as json_file:
data = json.load(json_file)
data["username"] = username
if not username:
username = "New User"
data["username"] = username
welcome_label.configure(text=f"Welcome, {username}!")
cancel_username_changes()
with open('src/user_settings.json', 'w') as f:
json.dump(data, f)
def cancel_username_changes():
update_password_button.destroy()
change_username_entry.destroy()
cancel_change_button.destroy()
def open_YTD():
app.destroy()
subprocess.run(["python", "src/YTD/YTD.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_DSP():
app.destroy()
subprocess.run(["python", "src/DSP/DSP.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_DO():
app.destroy()
subprocess.run(["python", "src/DO/do.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_W2PDF():
app.destroy()
subprocess.run(["python", "src/W2PDF/w2pdf.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_V2TXT():
app.destroy()
subprocess.run(["python", "src/V2TXT/V2TXT.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_FDCL():
app.destroy()
subprocess.run(["python", "src/FD/FDCL.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_GS():
app.destroy()
subprocess.run(["python", "src/GS/GS.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_GPTS():
app.destroy()
subprocess.run(["python", "src/GPTS/GPTS.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_TT():
app.destroy()
subprocess.run(["python", "src/TT/TT.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_PCW():
app.destroy()
subprocess.run(["python", "src/PCW/PCW.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_QRG():
app.destroy()
subprocess.run(["python", "src/QRG/QRG.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def open_MN():
app.destroy()
subprocess.run(["python", "src/MN/MN.pyw"],
creationflags=subprocess.CREATE_NO_WINDOW)
def toggle_theme():
with open("src/settings.json", "r")as f:
settings = json.load(f)
theme = settings['theme']
if theme == 'Dark':
CTk.set_appearance_mode("Light")
toggle_theme_button.configure(text="\u26ee")
settings['theme'] = 'Light'
if theme == 'Light':
CTk.set_appearance_mode("Dark")
toggle_theme_button.configure(text="\u2600")
settings['theme'] = 'Dark'
with open('src/settings.json', 'w') as f:
json.dump(settings, f)
def check_for_updates():
r = requests.get("https://api.github.com/repos/ziadh/Desky/releases")
json_data = r.json()
newest_version = json_data[0]["tag_name"]
if float(newest_version) > float(version):
version_message.configure(
text=f"New update v{newest_version} available. Click me to update.")
version_message.bind("<Button-1>", download_update)
else:
whats_new_label.configure(
text=f"You are running the latest version v{version}. Click me to view\nthe latest changes.")
whats_new_label.bind("<Button-1>", open_release_notes)
def open_release_notes(event):
r = requests.get("https://api.github.com/repos/ziadh/Desky/releases")
json_data = r.json()
newest_version = json_data[0]["tag_name"]
notes_link = f"https://github.com/ziadh/Desky/releases/tag/{newest_version}"
webbrowser.open(notes_link)
def download_update(event):
r = requests.get("https://api.github.com/repos/ziadh/Desky/releases")
json_data = r.json()
newest_version = json_data[0]["tag_name"]
link = "https://github.com/ziadh/Desky/archive/refs/tags/"+newest_version+".zip"
webbrowser.open(link)
def exit_app():
confirm = messagebox.askyesno(
title='Confirm Exit', message=' Are you sure you would like to exit?')
if confirm:
app.destroy()
def open_github_page():
confirm_open = messagebox.askyesno("Confirm Open GitHub","Are you sure you would like to open the project's GitHub page?")
if confirm_open:
link = "https://github.com/ziadh/Desky/"
webbrowser.open(link)
with open("src/settings.json", 'r')as f:
settings = json.load(f)
with open("src/user_settings.json", 'r')as f:
user_settings = json.load(f)
version = settings['version']
username = user_settings['username']
theme = settings['theme']
if theme == 'Dark':
CTk.set_appearance_mode("Dark")
else:
CTk.set_appearance_mode("Light")
CTk.set_default_color_theme("blue")
app = CTk.CTk()
app.bind("<Return>", lambda _: update_password_button.invoke())
app.bind("<Escape>", lambda _: cancel_change_button.invoke())
app.geometry("600x630")
app.title(f"Desky v{version}")
app.resizable(False, False)
app.wm_iconbitmap('assets/logos/Desky-logo.ico')
welcome_label = CTk.CTkLabel(
app, text=f"Welcome, {username}!", font=("Arial", 20))
welcome_label.place(x=10, y=10)
change_username_button = CTk.CTkButton(
app, text="Change Name", font=("Arial", 20), command=update_username)
change_username_button.place(x=430, y=10)
top_seperator = CTk.CTkLabel(
app, text="^"*157)
top_seperator.place(x=-20, y=50)
apps_label = CTk.CTkLabel(app, text="My Apps", font=("Arial", 20))
apps_label.place(x=250, y=70)
DSP_button = CTk.CTkButton(app, text="Daily Sneak Peek", font=(
"Arial", 20), command=open_DSP)
DSP_button.place(x=10, y=110)
DO_button = CTk.CTkButton(app, text="Downloads Organizer", font=(
"Arial", 20), command=open_DO)
DO_button.place(x=10, y=170)
FDCL_button = CTk.CTkButton(app, text="Fresh Desktop Checklist",
font=("Arial", 20), command=open_FDCL)
FDCL_button.place(x=10, y=230)
GS_button = CTk.CTkButton(app, text="Google Search", font=("Arial",20),command=open_GS)
GS_button.place(x=10,y=290)
GPTS_button = CTk.CTkButton(app, text='GPT-3.5 Search',
font=("Arial", 20), command=open_GPTS)
GPTS_button.place(x=10, y=350)
MN_button = CTk.CTkButton(app, text="My Notes",
font=("Arial", 20), command=open_MN, anchor="w", width=20)
MN_button.place(x=10, y=410)
PCW_button = CTk.CTkButton(app, text="PC Watcher", font=(
"Arial", 20), command=open_PCW, width=20, anchor="w")
PCW_button.place(x=10, y=470)
QRG_button = CTk.CTkButton(app, text="QR Generator", font=(
"Arial", 20), command=open_QRG, width=20, anchor="w")
QRG_button.place(x=410, y=110)
TT_button = CTk.CTkButton(app, text='Tock Tick',
font=("Arial", 20), command=open_TT, width=20, anchor="w")
TT_button.place(x=410, y=170)
W2PDF_button = CTk.CTkButton(app, text="Word To PDF", font=(
"Arial", 20), command=open_W2PDF)
W2PDF_button.place(x=410, y=230)
v2txt_button = CTk.CTkButton(app, text="Voice to Text", font=(
"Arial", 20), command=open_V2TXT)
v2txt_button.place(x=410, y=290)
YTD_button = CTk.CTkButton(app, text="YT Downloader", font=(
"Arial", 20), command=open_YTD)
YTD_button.place(x=410, y=350)
bottom_seperator = CTk.CTkLabel(app, text="v"*157)
bottom_seperator.place(x=-20, y=510)
github_page_button = CTk.CTkButton(
app, text='GitHub', width=30, command=open_github_page)
github_page_button.place(x=150, y=585)
toggle_theme_button = CTk.CTkButton(app, text="\u2600", font=(
"Arial", 16), width=3, command=toggle_theme)
toggle_theme_button.place(x=385, y=585)
check_for_updates_button = CTk.CTkButton(app, text="Check for Updates", font=(
"Arial", 16), command=check_for_updates)
check_for_updates_button.place(x=220, y=585)
exit_button = CTk.CTkButton(app, text="Exit", font=(
"Arial", 16), command=exit_app)
exit_button.place(x=430, y=585)
version_message = CTk.CTkLabel(app, text="", font=("Arial", 16))
version_message.place(x=0, y=530)
whats_new_label = CTk.CTkLabel(app, text="", font=("Arial", 16))
whats_new_label.place(x=0, y=530)
app.mainloop()
sys.stderr.close()
if os.path.getsize(log_path) == 0:
os.remove(log_path)
os.rmdir(log_folder)