· 4 years ago · Mar 16, 2021, 05:48 PM
1import tkinter as tk
2import ast
3from tkinter import messagebox, simpledialog, filedialog
4import sys
5import os
6from threading import Thread
7import time
8try:
9 import gspread
10except ModuleNotFoundError:
11 os.system("pip install gspread")
12 import gspread
13try:
14 from oauth2client.service_account import ServiceAccountCredentials
15except ModuleNotFoundError:
16 os.system('pip install oauth2client')
17 from oauth2client.service_account import ServiceAccountCredentials
18try:
19 import getpass
20except ModuleNotFoundError:
21 os.system("pip install getpass")
22 import getpass
23try:
24 import random
25except ModuleNotFoundError:
26 os.system('pip install random')
27 import random
28try:
29 import pyglet as tpg
30except ModuleNotFoundError:
31 os.system('pip install pyglet')
32 import pyglet as tpg
33
34sys.setrecursionlimit(10**6)
35
36tmversion = 'TechMail TechOSV pre00.07_04'
37
38global root_0
39root_0 = frame1
40
41# Images
42global photofile
43photofile = os.path.join(sys.path[0], 'Attributes\Icon.png')
44photofile = 'T:/Programs/TechMail/Attributes/Icon.png'
45global logoimage
46logoimage = os.path.join(sys.path[0], 'Attributes\Techpad Logo.png')
47logoimage = 'T:/Programs/TechMail/Attributes/Techpad Logo.png'
48logophoto = tk.PhotoImage(file=logoimage)
49global loadingimage
50loadingimage = os.path.join(sys.path[0], 'Attributes\Loading.gif')
51loadingimage = 'T:/Programs/TechMail/Attributes/Loading.gif'
52global largeicon
53largeiconfile = os.path.join(sys.path[0], 'Attributes\Large Icon v2.png')
54largeiconfile = 'T:/Programs/TechMail/Attributes/Large Icon v2.png'
55largeicon = tk.PhotoImage(file=largeiconfile)
56global loginbuttonimage
57loginbuttonfile = os.path.join(sys.path[0], 'Attributes\LoginButton.png')
58loginbuttonfile = 'T:/Programs/TechMail/Attributes/LoginButton.png'
59loginbuttonimage = tk.PhotoImage(file=loginbuttonfile)
60global loginpressedimage
61loginpressedfile = os.path.join(sys.path[0], 'Attributes\LoginButtonPressed.png')
62loginpressedfile = 'T:/Programs/TechMail/Attributes/LoginButtonPressed.png'
63loginpressedimage = tk.PhotoImage(file=loginpressedfile)
64global signupbuttonimage
65signupbuttonfile = os.path.join(sys.path[0], 'Attributes\SignupButton.png')
66signupbuttonfile = 'T:/Programs/TechMail/Attributes/SignupButton.png'
67signupbuttonimage = tk.PhotoImage(file=signupbuttonfile)
68global signuppressedimage
69signuppressedfile = os.path.join(sys.path[0], 'Attributes\SignupButtonPressed.png')
70signuppressedfile = 'T:/Programs/TechMail/Attributes/SignupButtonPressed.png'
71signuppressedimage = tk.PhotoImage(file=signuppressedfile)
72
73logolabel = tk.Label(root_0, bg='white', anchor='center')
74logolabel.image = logophoto
75logolabel.config(image=logolabel.image)
76logolabel.place(relwidth=1.0, relheight=1.0)
77versionlabel = tk.Label(root_0, text=tmversion, bg='white', anchor='center', font='arial 10')
78versionlabel.pack(side='bottom', pady=50, anchor='s')
79
80def runprogram():
81 global ast, messagebox, simpledialog, filedialog, tk, os, sys, gspread, ServiceAccountCredentials, getpass, random, tpg, root_0, Thread, time
82
83 # Scope for Google Drive API
84 scope = [
85 'https://www.googleapis.com/auth/drive',
86 'https://www.googleapis.com/auth/drive.file'
87 ]
88
89 # File for login key
90 file_name = os.path.join(sys.path[0], 'API\client_key.json')
91
92 # Experimental Files
93 file_name = 'T:/Programs/TechMail/API/client_key.json'
94
95 # Login
96 creds = ServiceAccountCredentials.from_json_keyfile_name(file_name, scope)
97 client = gspread.authorize(creds)
98
99 global python_emailsheet
100 global python_accountsheet
101
102 # Open Spreadsheets
103 try:
104 emailsheet = client.open('TechMail Emails').sheet1
105 python_emailsheet = emailsheet.get_all_records()
106 accountsheet = client.open('TechMail Accounts').sheet1
107 python_accountsheet = accountsheet.get_all_records()
108 except gspread.exceptions.APIError:
109 messagebox.showinfo('Server Error', 'The TechMail servers are experiencing high traffic. We will try loading again when they are back online.')
110 time.sleep(100)
111 try:
112 emailsheet = client.open('TechMail Emails').sheet1
113 python_emailsheet = emailsheet.get_all_records()
114 accountsheet = client.open('TechMail Accounts').sheet1
115 python_accountsheet = accountsheet.get_all_records()
116 except gspread.exceptions.APIError:
117 messagebox.showinfo('Server Error',
118 'The TechMail servers are still experiencing high traffic. Please try again later.')
119 sys.exit()
120 root_0.destroy()
121 except:
122 messagebox.showinfo("Client Error", "Your internet seems to be having trouble. Check for any apps that might be using up your resources.")
123
124 fontfile = os.path.join(sys.path[0], 'Attributes\TMFont.ttf')
125 fontfile = 'T:/Programs/TechMail/Attributes/TMFont.ttf'
126 tpg.font.add_file(fontfile)
127
128 global tpcreds
129 global uname
130 global rname
131
132 # Get Techpad Credentials
133 try:
134 tpcredsfile = open('C:/Program Files/Techpad/Techpad Credentials/Creds.stpc', 'r')
135 tpcredsfull = tpcredsfile.read()
136 tpcredstext = tpcredsfull[8:]
137 tpcreds = ast.literal_eval(tpcredstext)
138 tpcredsfile.close()
139 except:
140 tpcreds = [0]
141
142 # Make temporary user variables
143 uname = "Guest"
144 rname = "Guest"
145
146 # Tips & tricks
147 tips = [
148 "Press refresh to see new emails!",
149 "Press logout to switch accounts!",
150 "You can send up to one attachment per email.",
151 "An email attachment can be no more than 50 KB.",
152 "You can't hack Techpad ¯\_(?)_/¯",
153 "Email Techpad at Techpad@techmail.com if you have questions or feedback!",
154 "Read the changelog to see what's new!",
155 "TechMail has no easter eggs. At least, none that we know of.",
156 "Use the reply button in an email for a quick way to reply!",
157 "More features coming soon!",
158 "TechMail is written in Python!",
159 "If the email preview is bold, it means you haven't read it yet.",
160 "You can access previous versions of TechMail in the Versions folder (as long as they're stable.)",
161 "Yeet!",
162 "TechMail uses multithreaded processing!",
163 "Does anybody care about these tips?",
164 "You can't delete emails... yet.",
165 "You need internet for TechMail to work.",
166 "Don't look at the console! There's nothing important there.",
167 "If you used the installer, TechMail is on your home screen!",
168 "You can make your TechMail address whatever you want!",
169 "Anyone can see your name! Be careful.",
170 "Make sure you use a good password!",
171 "Did you know? The first versions of TechMail were console based!",
172 "Check out some other Techpad apps!",
173 "New emails appear on top!",
174 "Over 1,000 lines of code!"
175 ]
176
177 eastereggtips = [
178 "If you have 666 emails in your inbox, then they will all say yeet",
179 "Big Chungus likes potatoes",
180 "TechMail has over 100 useless lines of code",
181 "Earth is a ravioli",
182 "Life is a hallucination caused by breathing. Once you stop breathing, the hallucination ends",
183 "The point of golf is to play as little golf as possible",
184 "You can breathe underwater if you'ree smart enough",
185 "Whatever you do, do not enjoy Yeeting Simulator. It sucks",
186 "Whatever you do, do NOT eat the free pistachio ice cream. It has TURNED.",
187 "Moo",
188 "Bruh",
189 "Fun fact: At least 5 people live in Australia",
190 "Everyone who has come into contact with water will die",
191 """Never gonna give you up
192Never gonna let you down
193Never gonna run around and desert you
194Never gonna make you cry
195Never gonna say goodbye
196Never gonna tell a lie and hurt you""",
197 "Disco Fish",
198 "Disco Shrek",
199 "Yeet",
200 "Fun fact: If you stab yourself, you'll bleed",
201 "The sunglasses ate your coffee",
202 "Click here for an egg salad subcontrabass piccolo dish"
203 ]
204
205 global global_bg_color
206 global_bg_color = 'white'
207
208 def update_sheets():
209 global python_emailsheet
210 global python_accountsheet
211 python_emailsheet = emailsheet.get_all_records()
212 python_accountsheet = accountsheet.get_all_records()
213
214 # Function to find row based on text in column
215 def getrow(col, text, sheet):
216 if sheet == 'account': # For finding account information
217 row = 0
218 for element in python_accountsheet:
219 if element[col] == text:
220 return row
221 break
222 else:
223 row += 1
224 else:
225 return None
226 elif sheet == 'email': # For finding emails based on account
227 row = 0
228 matchingrows = []
229 for element in python_emailsheet:
230 if element[col] == text:
231 matchingrows.append(row)
232 row += 1
233 else:
234 row += 1
235 return matchingrows
236
237 def signup(): # Function to make an account
238 try:
239 titlelabel.destroy()
240 loginbutton.destroy()
241 spacer.destroy()
242 signupbutton.destroy()
243 except:
244 pass
245 global newusernamelabel
246 newusernamelabel = tk.Label(root_0, text="Create a TechMail Address (@techmail.com)", justify="left", bg=global_bg_color, font='Quicksand 10')
247 global namelabel
248 namelabel = tk.Label(root_0, text="Name", justify="left", bg=global_bg_color, font='Quicksand 10')
249 global newpasswordlabel
250 newpasswordlabel = tk.Label(root_0, text="Create a Password", justify="left", bg=global_bg_color, font='Quicksand 10')
251 global verifypasswordlabel
252 verifypasswordlabel = tk.Label(root_0, text="Verify your Password", justify="left", bg=global_bg_color, font='Quicksand 10')
253 global newusernameinput
254 newusernameinput = tk.Entry(root_0, width=30, bd=1, relief='solid', font='Quicksand 10')
255 global nameinput
256 nameinput = tk.Entry(root_0, width=30, bd=1, relief='solid', font='Quicksand 10')
257 global newpasswordinput
258 newpasswordinput = tk.Entry(root_0, width=30, bd=1, relief='solid', show='\u2022', font='Quicksand 10')
259 global verifypasswordinput
260 verifypasswordinput = tk.Entry(root_0, width=30, bd=1, relief='solid', show='\u2022', font='Quicksand 10')
261 global signupformsubmit
262 signupformsubmit = tk.Button(root_0, text="Sign up", command=evaluatesignup, bg='white', bd=1, relief='solid', activebackground='#ddeeff', font='Quicksand 10', cursor='hand2')
263 global signuploginbutton
264 signuploginbutton = tk.Button(root_0, text="Already have an account? Log in", command=signuplogin, bg='white', bd=0, relief='solid', activebackground='white', activeforeground='#00afff', font='Quicksand 10', cursor='hand2')
265 newusernamelabel.place(x=5, y=5)
266 newusernameinput.place(x=5, y=25)
267 namelabel.place(x=5, y=45)
268 nameinput.place(x=5, y=65)
269 newpasswordlabel.place(x=5, y=85)
270 newpasswordinput.place(x=5, y=105)
271 verifypasswordlabel.place(x=5, y=125)
272 verifypasswordinput.place(x=5, y=145)
273 signupformsubmit.place(x=5, y=175)
274 signuploginbutton.place(x=5, y=210)
275
276 def evaluatesignup():
277 newusername = newusernameinput.get()
278 newpassword = newpasswordinput.get()
279 verifypassword = verifypasswordinput.get()
280 name = nameinput.get()
281 if newpassword == verifypassword:
282 global python_emailsheet
283 global python_accountsheet
284 update_sheets()
285 rownumber = len(python_accountsheet) + 2 # Get how many rows there are and add 1
286 emailrownumber = len(python_emailsheet) + 2
287 row = [newusername, name, newpassword] # Row to add
288 body = "A new account has been made. Check for spam.\nTechMail Address: " + newusername + "\nName: " + name + "\nPassword: " + newpassword
289 emailrow = ["Techpad@techmail.com", "TechMailActivity@techmail.com", "New Account Made", body]
290 accountsheet.insert_row(row, rownumber) # Add the row
291 emailsheet.insert_row(emailrow, emailrownumber)
292 messagebox.showinfo("Signup Successful",
293 "Your account has been successfully created. You will need to log in again.")
294 uname = newusername
295 rname = name
296 newusernamelabel.destroy()
297 namelabel.destroy()
298 newpasswordlabel.destroy()
299 verifypasswordlabel.destroy()
300 newusernameinput.destroy()
301 nameinput.destroy()
302 newpasswordinput.destroy()
303 verifypasswordinput.destroy()
304 signupformsubmit.destroy()
305 logout()
306 else:
307 messagebox.showinfo("Passwords do not match", "Your passwords do not match. Please try again.")
308
309 def loginsignup():
310 usernamelabel.destroy()
311 passwordlabel.destroy()
312 usernameinput.destroy()
313 passwordinput.destroy()
314 loginformsubmit.destroy()
315 loginsignupbutton.destroy()
316 signup()
317
318 def signuplogin():
319 newusernamelabel.destroy()
320 namelabel.destroy()
321 newpasswordlabel.destroy()
322 verifypasswordlabel.destroy()
323 newusernameinput.destroy()
324 nameinput.destroy()
325 newpasswordinput.destroy()
326 verifypasswordinput.destroy()
327 signupformsubmit.destroy()
328 signuploginbutton.destroy()
329 login()
330
331 def login(): # Function to login
332 try:
333 titlelabel.destroy()
334 loginbutton.destroy()
335 spacer.destroy()
336 signupbutton.destroy()
337 except:
338 pass
339 global usernamelabel
340 usernamelabel = tk.Label(root_0, text="TechMail Address", justify="left", bg=global_bg_color, font='Quicksand 10')
341 global passwordlabel
342 passwordlabel = tk.Label(root_0, text="Password", justify="left", bg=global_bg_color, font='Quicksand 10')
343 global usernameinput
344 usernameinput = tk.Entry(root_0, width=30, bd=1, relief='solid', font='Quicksand 10')
345 global passwordinput
346 passwordinput = tk.Entry(root_0, width=30, bd=1, relief='solid', show='\u2022', font='Quicksand 10')
347 global loginformsubmit
348 loginformsubmit = tk.Button(root_0, text="Login", command=evaluatelogin, bg='white', bd=1, relief='solid', activebackground='#ddeeff', font='Quicksand 10', cursor='hand2')
349 global loginsignupbutton
350 loginsignupbutton = tk.Button(root_0, text="Don't have an account? Sign up", command=loginsignup, bg='white', bd=0, relief='solid', activebackground='white', activeforeground='#00afff', font='Quicksand 10', cursor='hand2')
351 usernamelabel.place(x=5, y=5)
352 usernameinput.place(x=5, y=25)
353 passwordlabel.place(x=5, y=45)
354 passwordinput.place(x=5, y=65)
355 loginformsubmit.place(x=5, y=95)
356 loginsignupbutton.place(x=5, y=130)
357
358 def evaluatelogin():
359 global uname
360 global rname
361 global python_emailsheet
362 global python_accountsheet
363 username = usernameinput.get()
364 password = passwordinput.get()
365 musername = getrow("Address", username, "account")
366 if musername == None: # If it is not
367 messagebox.showinfo("Invalid TechMail Address",
368 "The TechMail Address you entered is invalid. Please try again.")
369 else: # If valid TechMail Address, ask for password
370 if username == 'Techpad@techmail.com':
371 index = 0
372 if not len(tpcreds) == 1:
373 for element in tpcreds:
374 if element == 'Techpad':
375 nextindex = index + 1
376 if tpcreds[nextindex] == 'N#hrnvHN*&@3hrnHND98Nr9':
377 uname = 'Techpad@techmail.com'
378 rname = 'Techpad'
379 checkemails()
380 break
381 else:
382 messagebox.showinfo("Access Denied",
383 "You do not have access to that account. Please try again.")
384 break
385 else:
386 index += 1
387 else:
388 messagebox.showinfo("Access Denied",
389 "You do not have access to that account. Please try again.")
390 else:
391 messagebox.showinfo("Access Denied", "You do not have access to that account. Please try again.")
392 elif username == 'TechMailActivity@techmail.com':
393 index = 0
394 if not len(tpcreds) == 1:
395 for element in tpcreds:
396 if element == 'TechMailActivity':
397 nextindex = index + 1
398 if tpcreds[nextindex] == '(*m(8hdfm^f%SVf56B0nf*&GWf':
399 uname = 'TechMailActivity@techmail.com'
400 rname = 'TechMail Activity'
401 checkemails()
402 break
403 else:
404 messagebox.showinfo("Access Denied",
405 "You do not have access to that account. Please try again.")
406 break
407 else:
408 index += 1
409 else:
410 messagebox.showinfo("Access Denied",
411 "You do not have access to that account. Please try again.")
412 else:
413 messagebox.showinfo("Access Denied", "You do not have access to that account. Please try again.")
414 elif username == 'Techpjm@techmail.com':
415 index = 0
416 if not len(tpcreds) == 1:
417 for element in tpcreds:
418 if element == 'TechPJM':
419 nextindex = index + 1
420 if tpcreds[nextindex] == 'NV#rn7E(D*F83r*F((Sd9f388NE':
421 uname = 'Techpjm@techmail.com'
422 rname = 'TechPJM'
423 checkemails()
424 break
425 else:
426 messagebox.showinfo("Access Denied",
427 "You do not have access to that account. Please try again.")
428 break
429 else:
430 index += 1
431 else:
432 messagebox.showinfo("Access Denied",
433 "You do not have access to that account. Please try again.")
434 else:
435 messagebox.showinfo("Access Denied", "You do not have access to that account. Please try again.")
436 else:
437 update_sheets()
438 truepassword = python_accountsheet[musername]["Password"]
439 if password == truepassword: # Compare passwords
440 name = python_accountsheet[musername]["Name"] # Get name
441 username = python_accountsheet[musername]["Address"] # Get username
442 uname = username # Set username variable
443 rname = name # Set real name variable
444 checkemails() # Start using TechMail
445 else: # If passwords do not match
446 messagebox.showinfo("Password Incorrect",
447 "The password you entered did not match the username. Please try again.")
448
449# def settings(): - Does not work well currently
450# global global_bg_color
451# settings = tk.Toplevel(root_0)
452# settings.title("Settings - TechMail")
453# settings.iconphoto(False, tk.PhotoImage(file=photofile))
454# settings.minsize(400, 300)
455# settings.maxsize(400, 300)
456# settings.resizable(False, False)
457# settings.configure(bg=global_bg_color)
458# settingslabel = tk.Label(settings, text='Settings', font='Quicksand 40', pady=20, bg='white', fg='dodgerblue')
459# settingslabel.pack(anchor='nw')
460# bgcolorname = tk.StringVar()
461# if global_bg_color == 'white':
462# bgcolorname.set('White')
463# elif global_bg_color == 'lightgray':
464# bgcolorname.set('Light Gray')
465# elif global_bg_color == '#ffcccc':
466# bgcolorname.set('Red')
467# elif global_bg_color == '#ffeecc':
468# bgcolorname.set('Orange')
469# elif global_bg_color == '#ffffcc':
470# bgcolorname.set('Yellow')
471# elif global_bg_color == '#ccffcc':
472# bgcolorname.set('Green')
473# elif global_bg_color == '#ddeeff':
474# bgcolorname.set('Light Blue')
475# elif global_bg_color == '#ccccff':
476# bgcolorname.set('Blue')
477# elif global_bg_color == '#ffccff':
478# bgcolorname.set('Purple')
479# def changebg():
480# global global_bg_color
481# if global_bg_color == 'white':
482# global_bg_color = 'lightgray'
483# elif global_bg_color == 'lightgray':
484# global_bg_color = '#ffcccc'
485# elif global_bg_color == '#ffcccc':
486# global_bg_color = '#ffeecc'
487# elif global_bg_color == '#ffeecc':
488# global_bg_color = '#ffffcc'
489# elif global_bg_color == '#ffffcc':
490# global_bg_color = '#ccffcc'
491# elif global_bg_color == '#ccffcc':
492# global_bg_color = '#ddeeff'
493# elif global_bg_color == '#ddeeff':
494# global_bg_color = '#ccccff'
495# elif global_bg_color == '#ccccff':
496# global_bg_color = '#ffccff'
497# elif global_bg_color == '#ffccff':
498# global_bg_color = 'white'
499# if global_bg_color == 'white':
500# bgcolorname.set('White')
501# elif global_bg_color == 'lightgray':
502# bgcolorname.set('Light Gray')
503# elif global_bg_color == '#ffcccc':
504# bgcolorname.set('Red')
505# elif global_bg_color == '#ffeecc':
506# bgcolorname.set('Orange')
507# elif global_bg_color == '#ffffcc':
508# bgcolorname.set('Yellow')
509# elif global_bg_color == '#ccffcc':
510# bgcolorname.set('Green')
511# elif global_bg_color == '#ddeeff':
512# bgcolorname.set('Light Blue')
513# elif global_bg_color == '#ccccff':
514# bgcolorname.set('Blue')
515# elif global_bg_color == '#ffccff':
516# bgcolorname.set('Purple')
517# root_0.configure(bg=global_bg_color)
518# changebgbutton = tk.Button(settings, textvar=bgcolorname, font='Quicksand 15', padx=5, pady=5, command=changebg, bg='white', bd=1, relief='solid', activebackground='#ddeeff')
519# changebgbutton.pack(anchor='nw', padx=5)
520
521 def character_limit(entry_text):
522 if len(entry_text.get()) > 24:
523 entry_text.set(entry_text.get()[:24])
524
525 def help():
526 helpwcode = """import tkinter as tk
527helpw = frame1
528helplabel = tk.Label(helpw, text='Help', font='Quicksand 25', pady=20, bg='white', fg='dodgerblue', padx=5)
529helplabel.pack(side='top', anchor='nw')
530helpinfotext = '''- To display an email, click on the email preview.\n\n- To send an email, press \"Compose\" and then fill out the form. You may choose to add an attachment from your files.\n\n- To reply to an email, click \"Reply\" while in an email. It will automatically fill out most of the form for you.\n\n- To check if you have any new emails, press \"Refresh\".\n\n- To download an attachment, click the button at the bottom of an email next to the reply button. It will ask you to download the attachment. Place it in a folder where you can find and open it.\n\n- To sign in with a different account, press \"Logout\".\n\n- To edit your account information, press \"Account\".'''
531helpinfo = tk.Label(helpw, text=helpinfotext, padx=5, bg='white', wraplength=590, justify='left')
532helpinfo.pack(side='top', anchor='nw')"""
533 helpwindow = create_window(x=150, y=150, width=600, height=400, img='T:/Programs/TechMail/Attributes/Icon.png', title='Help - TechMail', code=helpwcode)
534
535 def account():
536 update_sheets()
537 accountw = tk.Toplevel(root)
538 accountw.title('Account - TechMail')
539 accountw.configure(bg=global_bg_color)
540 accountw.minsize(600, 400)
541 accountw.maxsize(600, 400)
542 accountw.resizable(False, False)
543 accountw.iconphoto(False, tk.PhotoImage(file=photofile))
544 def changeaccinfo():
545 update_sheets()
546 accountrow = getrow("Address", uname, 'account') + 2
547 if accnewpasswordinput.get() == accverifypasswordinput.get():
548 accountsheet.update_cell(accountrow, 2, accnameinput.get())
549 accountsheet.update_cell(accountrow, 3, accnewpasswordinput.get())
550 else:
551 messagebox.showinfo("Passwords do not match", "Your new passwords do not match. Please try again.")
552 accountlabel = tk.Label(accountw, text='Account Settings', font='Quicksand 40', pady=20, bg='white', fg='dodgerblue')
553 accnewusernamelabel = tk.Label(accountw, text="TechMail Address", justify="left",
554 bg=global_bg_color)
555 accnamelabel = tk.Label(accountw, text="Name", justify="left", bg=global_bg_color)
556 accnewpasswordlabel = tk.Label(accountw, text="Password", justify="left", bg=global_bg_color)
557 accverifypasswordlabel = tk.Label(accountw, text="Verify password", justify="left", bg=global_bg_color)
558 accusernameinput = tk.Label(accountw, text=uname, justify="left", bg=global_bg_color)
559 accnameinput = tk.Entry(accountw, width=30, bd=1, relief='solid')
560 accnewpasswordinput = tk.Entry(accountw, width=30, bd=1, relief='solid', show='\u2022')
561 accverifypasswordinput = tk.Entry(accountw, width=30, bd=1, relief='solid', show='\u2022',)
562 accformsubmit = tk.Button(accountw, text="Save", command=changeaccinfo, bg='white', bd=1, relief='solid',
563 activebackground='#ddeeff', cursor='hand2')
564 accountrow = getrow("Address", uname, 'account')
565 accusernameinput.config(text=uname)
566 accnameinput.insert(0, python_accountsheet[accountrow]["Name"])
567 accnewpasswordinput.insert(0, python_accountsheet[accountrow]["Password"])
568 accverifypasswordinput.insert(0, python_accountsheet[accountrow]["Password"])
569 accountlabel.pack(side='top', anchor='nw', padx=5)
570 accnewusernamelabel.pack(side='top', anchor='w', padx=5)
571 accusernameinput.pack(side='top', anchor='w', padx=5)
572 accnamelabel.pack(side='top', anchor='w', padx=5)
573 accnameinput.pack(side='top', anchor='w', padx=5)
574 accnewpasswordlabel.pack(side='top', anchor='w', padx=5)
575 accnewpasswordinput.pack(side='top', anchor='w', padx=5)
576 accverifypasswordlabel.pack(side='top', anchor='w', padx=5)
577 accverifypasswordinput.pack(side='top', anchor='w', padx=5)
578 accformsubmit.pack(side='top', anchor='sw', padx=5, pady=5)
579
580 def inbox():
581 todo = simpledialog.askstring("Inbox", "Type the number of the email in your inbox that you want to display:",
582 parent=root_0)
583 inboxrows = getrow(1, uname, 'email')
584 if inboxrows[0] == 0:
585 messagebox.showinfo("No emails", "You have no emails in your inbox.")
586 else:
587 email = int(todo) - 1
588 try:
589 emailrow = inboxrows[int(email)]
590 fromemail = emailsheet.cell(emailrow, 2).value
591 subject = emailsheet.cell(emailrow, 3).value
592 text = emailsheet.cell(emailrow, 4).value
593 global emailattachment
594 emailattachment = emailsheet.cell(emailrow, 5).value
595 fromaccount = getrow(1, fromemail, 'account')
596 if fromaccount == 0:
597 fromname = "Unknown"
598 else:
599 fromname = accountsheet.cell(fromaccount, 2).value
600 emailmessage = tk.Toplevel(root_0)
601 emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
602 tovar = tk.StringVar()
603 fromvar = tk.StringVar()
604 subjectvar = tk.StringVar()
605 bodyvar = tk.StringVar()
606 emailattachmentname = tk.StringVar()
607 tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
608 fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
609 subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
610 bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
611 replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, fromemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
612 def downloadattachment():
613 global emailattachment
614 downloadattachmentname = emailattachment.partition('<Name Conts>')[0]
615 downloadattachmentcontents = emailattachment.partition('<Name Conts>')[2]
616 downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
617 if not downloadname == '':
618 downloadfile = open(downloadname, 'wb')
619 downloadfile.write(downloadattachmentcontents.encode('latin1'))
620 downloadfile.close()
621 else:
622 pass
623 emailmessage.minsize(600, 400)
624 emailmessage.maxsize(600, 600)
625 emailmessage.resizable(False, True)
626 emailmessage.configure(bg=global_bg_color)
627 tovar.set('To: Me (' + uname + ')')
628 fromvar.set('From: ' + fromname + ' (' + fromemail + ')')
629 subjectvar.set('Subject: ' + subject)
630 bodyvar.set(text)
631 tolabel.place(x=10, y=10)
632 fromlabel.place(x=10, y=30)
633 subjectlabel.place(x=10, y=50)
634 bodylabel.place(x=10, y=85)
635 if not emailattachment == '':
636 emailattachmentname.set(emailattachment.partition('<Name Conts>')[0])
637 emailattachmentbutton = tk.Button(emailmessage, textvar=emailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
638 emailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
639 replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
640 emailmessage.title(subject + ' - TechMail')
641 global reademails
642 emailnumber = email + 1
643 if not emailnumber in reademails and not fromemail == 'TechMailActivity@techmail.com':
644 reademails.append(emailnumber)
645 reademailsfile = open(read_emails_file_name, "w")
646 reademailsfile.write(str(reademails))
647 reademailsfile.close()
648 except IndexError:
649 messagebox.showinfo("Email not found", "That email doesn't exist. Please try again.")
650
651 def inboxnew(targetnumber):
652 update_sheets()
653 inboxrows = getrow('To', uname, 'email')
654 if inboxrows == []:
655 messagebox.showinfo("Email not found", "Hmmm... This email seems to no longer exist. Please refresh and try again.")
656 else:
657 email = int(targetnumber) - 1
658 try:
659 emailrow = inboxrows[int(email)]
660 fromemail = python_emailsheet[emailrow]["From"]
661 subject = python_emailsheet[emailrow]["Subject"]
662 text = python_emailsheet[emailrow]["Text"]
663 global emailattachment
664 emailattachment = python_emailsheet[emailrow]["Attachment"]
665 fromaccount = getrow("Address", fromemail, 'account')
666 if fromaccount == None:
667 fromname = "Unknown"
668 else:
669 fromname = python_accountsheet[fromaccount]["Name"]
670 emailmessage = tk.Toplevel(root)
671 emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
672 tovar = tk.StringVar()
673 fromvar = tk.StringVar()
674 subjectvar = tk.StringVar()
675 bodyvar = tk.StringVar()
676 emailattachmentname = tk.StringVar()
677 tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
678 fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
679 subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
680 bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
681 replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, fromemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
682 def downloadattachment():
683 global emailattachment
684 downloadattachmentname = emailattachment.partition('<Name Conts>')[0]
685 downloadattachmentcontents = emailattachment.partition('<Name Conts>')[2]
686 downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
687 if not downloadname == '':
688 downloadfile = open(downloadname, 'wb')
689 downloadfile.write(downloadattachmentcontents.encode('latin1'))
690 downloadfile.close()
691 else:
692 pass
693 emailmessage.minsize(600, 400)
694 emailmessage.resizable(False, True)
695 emailmessage.configure(bg=global_bg_color)
696 tovar.set('To: Me (' + uname + ')')
697 fromvar.set('From: ' + fromname + ' (' + fromemail + ')')
698 subjectvar.set('Subject: ' + subject)
699 bodyvar.set(text)
700 tolabel.place(x=10, y=10)
701 fromlabel.place(x=10, y=30)
702 subjectlabel.place(x=10, y=50)
703 bodylabel.place(x=10, y=85)
704 if not emailattachment == '':
705 emailattachmentname.set(emailattachment.partition('<Name Conts>')[0])
706 emailattachmentbutton = tk.Button(emailmessage, textvar=emailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
707 emailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
708 replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
709 emailmessage.title(subject + ' - TechMail')
710 read = python_emailsheet[emailrow]["Read"]
711 if read == 'F':
712 emailsheet.update_cell(emailrow + 2, 6, 'T')
713 except IndexError:
714 messagebox.showinfo("Email not found", "Hmmm... This email seems to no longer exist. Please refresh and try again.")
715
716 def outbox():
717 todo = simpledialog.askstring("Outbox", "Type the number of the email in your outbox that you want to display:",
718 parent=root_0)
719 outboxrows = getrow(2, uname, 'email')
720 if outboxrows[0] == 0:
721 messagebox.showinfo("No emails", "You have not sent any emails.")
722 else:
723 email = int(todo) - 1
724 try:
725 emailrow = outboxrows[int(email)]
726 toemail = emailsheet.cell(emailrow, 1).value
727 subject = emailsheet.cell(emailrow, 3).value
728 text = emailsheet.cell(emailrow, 4).value
729 global sentemailattachment
730 sentemailattachment = emailsheet.cell(emailrow, 5).value
731 toaccount = getrow(1, toemail, 'account')
732 if toaccount == 0:
733 toname = "Unknown"
734 else:
735 toname = accountsheet.cell(toaccount, 2).value
736 emailmessage = tk.Toplevel(root_0)
737 emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
738 tovar = tk.StringVar()
739 fromvar = tk.StringVar()
740 subjectvar = tk.StringVar()
741 bodyvar = tk.StringVar()
742 sentemailattachmentname = tk.StringVar()
743 tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
744 fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
745 subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
746 bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
747 replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, toemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
748 def downloadattachment():
749 global sentemailattachment
750 downloadattachmentname = sentemailattachment.partition('<Name Conts>')[0]
751 downloadattachmentcontents = sentemailattachment.partition('<Name Conts>')[2]
752 downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
753 if not downloadname == '':
754 downloadfile = open(downloadname, 'wb')
755 downloadfile.write(downloadattachmentcontents.encode('latin1'))
756 downloadfile.close()
757 else:
758 pass
759 emailmessage.minsize(600, 400)
760 emailmessage.maxsize(600, 600)
761 emailmessage.resizable(False, True)
762 emailmessage.configure(bg=global_bg_color)
763 tovar.set('To: ' + toname + ' (' + toemail + ')')
764 fromvar.set('From: Me (' + uname + ')')
765 subjectvar.set('Subject: ' + subject)
766 bodyvar.set(text)
767 tolabel.place(x=10, y=10)
768 fromlabel.place(x=10, y=30)
769 subjectlabel.place(x=10, y=50)
770 bodylabel.place(x=10, y=85)
771 if not sentemailattachment == '':
772 sentemailattachmentname.set(sentemailattachment.partition('<Name Conts>')[0])
773 sentemailattachmentbutton = tk.Button(emailmessage, textvar=sentemailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
774 sentemailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
775 replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
776 emailmessage.title(subject + ' - TechMail')
777 except IndexError:
778 messagebox.showinfo("Email not found", "That email doesn't exist. Please try again.")
779
780 def outboxnew(targetnumber):
781 update_sheets()
782 outboxrows = getrow("From", uname, 'email')
783 if outboxrows == []:
784 messagebox.showinfo("Email not found", "Hmmm... This email seems to no longer exist. Please refresh and try again.")
785 else:
786 email = int(targetnumber) - 1
787 try:
788 emailrow = outboxrows[int(email)]
789 toemail = python_emailsheet[emailrow]["To"]
790 subject = python_emailsheet[emailrow]["Subject"]
791 text = python_emailsheet[emailrow]["Text"]
792 global sentemailattachment
793 sentemailattachment = python_emailsheet[emailrow]["Attachment"]
794 toaccount = getrow("Address", toemail, 'account')
795 if toaccount == None:
796 toname = "Unknown"
797 else:
798 toname = python_accountsheet[toaccount]["Name"]
799 emailmessage = tk.Toplevel(root)
800 emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
801 tovar = tk.StringVar()
802 fromvar = tk.StringVar()
803 subjectvar = tk.StringVar()
804 bodyvar = tk.StringVar()
805 sentemailattachmentname = tk.StringVar()
806 tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
807 fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
808 subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
809 bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
810 replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, toemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
811 def downloadattachment():
812 global sentemailattachment
813 downloadattachmentname = sentemailattachment.partition('<Name Conts>')[0]
814 downloadattachmentcontents = sentemailattachment.partition('<Name Conts>')[2]
815 downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
816 if not downloadname == '':
817 downloadfile = open(downloadname, 'wb')
818 downloadfile.write(downloadattachmentcontents.encode('latin1'))
819 downloadfile.close()
820 else:
821 pass
822 emailmessage.minsize(600, 400)
823 emailmessage.resizable(False, True)
824 emailmessage.configure(bg=global_bg_color)
825 tovar.set('To: ' + toname + ' (' + toemail + ')')
826 fromvar.set('From: Me (' + uname + ')')
827 subjectvar.set('Subject: ' + subject)
828 bodyvar.set(text)
829 tolabel.place(x=10, y=10)
830 fromlabel.place(x=10, y=30)
831 subjectlabel.place(x=10, y=50)
832 bodylabel.place(x=10, y=85)
833 if not sentemailattachment == '':
834 sentemailattachmentname.set(sentemailattachment.partition('<Name Conts>')[0])
835 sentemailattachmentbutton = tk.Button(emailmessage, textvar=sentemailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
836 sentemailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
837 replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
838 emailmessage.title(subject + ' - TechMail')
839 except IndexError:
840 messagebox.showinfo("Email not found", "That email doesn't exist. Please try again.")
841
842 def compose():
843 global composeform
844 composeform = tk.Toplevel(root)
845 composeform.iconphoto(False, tk.PhotoImage(file=photofile))
846 composeform.minsize(600, 469)
847 composeform.maxsize(600, 469)
848 composeform.resizable(False, False)
849 composeform.configure(bg=global_bg_color)
850 global toinput
851 global subjectinput
852 global bodyinput
853 global attachment
854 attachment = ''
855 global attachmentname
856 global attachmentvar
857 attachmentvar = tk.StringVar()
858 attachmentvar.set("")
859 def addattachment():
860 global attachment
861 global attachmentname
862 global attachmentvar
863 filepath = filedialog.askopenfilename(parent=composeform, filetypes=[('All Files', '*'), ('Text Files', '.txt'), ('Image Files', '.png .jpg'), ('Python Files', '.py .pyw')], title='Open File to Attach')
864 file = open(filepath, 'rb')
865 filetext = file.read().decode('latin1')
866 if len(filetext) > 50000:
867 messagebox.showinfo("Cannot load attachment", "We cannot load attachments over 50 KB. Please upload a different file.")
868 else:
869 attachmentname = os.path.basename(filepath)
870 attachmentvar.set(attachmentname)
871 attachment = attachmentname + "<Name Conts>" + filetext
872 tolabel = tk.Label(composeform, text="To", justify="left", bg=global_bg_color)
873 toinput = tk.Entry(composeform, width=30, bd=1, relief='solid')
874 subjectinputtext = tk.StringVar()
875 subjectlabel = tk.Label(composeform, text="Subject", justify="left", bg=global_bg_color)
876 subjectinput = tk.Entry(composeform, width=30, bd=1, relief='solid', textvar=subjectinputtext)
877 subjectinputtext.trace("w", lambda *args: character_limit(subjectinputtext))
878 bodylabel = tk.Label(composeform, text="Message", justify="left", bg=global_bg_color)
879 bodyframe = tk.Frame(composeform, bd=1, relief='solid')
880 bodyinput = tk.Text(bodyframe, font='TkDefaultFont', bd=0)
881 attachmentbutton = tk.Button(composeform, text="Attach", command=addattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
882 attachmentlabel = tk.Label(composeform, textvar=attachmentvar, justify="left", bg=global_bg_color)
883 composeformsubmit = tk.Button(composeform, text="Send", command=sendemail, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
884 tolabel.place(x=5, y=5)
885 toinput.place(x=5, y=25)
886 subjectlabel.place(x=5, y=45)
887 subjectinput.place(x=5, y=65)
888 bodylabel.place(x=5, y=85)
889 bodyframe.place(x=5, y=105, width=590, height=300)
890 bodyinput.pack(expand=True, fill='both')
891 attachmentbutton.place(x=5, y=410)
892 attachmentlabel.place(x=50, y=410)
893 composeformsubmit.place(x=5, y=440)
894
895 def reply(subject, toemail):
896 update_sheets()
897 global replyform
898 replyform = tk.Toplevel(root)
899 replyform.iconphoto(False, tk.PhotoImage(file=photofile))
900 replyform.minsize(600, 429)
901 replyform.maxsize(600, 429)
902 replyform.resizable(False, False)
903 replyform.configure(bg=global_bg_color)
904 toaccount = getrow("Address", toemail, 'account')
905 if toaccount == None:
906 toname = "Unknown"
907 else:
908 toname = python_accountsheet[toaccount]["Name"]
909 if subject[:4] == 'RE: ':
910 fullsubject = subject
911 else:
912 fullsubject = 'RE: ' + subject
913 global replybodyinput
914 global replyattachment
915 replyattachment = ''
916 global replyattachmentname
917 global replyattachmentvar
918 replyattachmentvar = tk.StringVar()
919 replyattachmentvar.set("")
920 def replyaddattachment():
921 global replyattachment
922 global replyattachmentname
923 global replyattachmentvar
924 filepath = filedialog.askopenfilename(parent=replyform,
925 filetypes=[('All Files', '*'), ('Text Files', '.txt'), ('Image Files', '.png .jpg'),
926 ('Python Files', '.py .pyw')], title='Open File to Attach')
927 file = open(filepath, 'rb')
928 filetext = file.read().decode('latin1')
929 if len(filetext) > 50000:
930 messagebox.showinfo("Cannot load attachment",
931 "We cannot load attachments over 50 KB. Please upload a different file.")
932 else:
933 replyattachmentname = os.path.basename(filepath)
934 replyattachmentvar.set(replyattachmentname)
935 replyattachment = replyattachmentname + "<Name Conts>" + filetext
936 tolabel = tk.Label(replyform, text="To: " + toname + " (" + toemail + ")", justify="left", bg=global_bg_color)
937 subjectlabel = tk.Label(replyform, text="Subject: " + fullsubject, justify="left", bg=global_bg_color)
938 bodylabel = tk.Label(replyform, text="Message", justify="left", bg=global_bg_color)
939 bodyframe = tk.Frame(replyform, bd=1, relief='solid')
940 replybodyinput = tk.Text(bodyframe, font='TkDefaultFont', bd=0)
941 replyattachmentbutton = tk.Button(replyform, text="Attach", command=replyaddattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
942 replyattachmentlabel = tk.Label(replyform, textvar=replyattachmentvar, justify="left", bg=global_bg_color, font='Quicksand 10')
943 replyformsubmit = tk.Button(replyform, text="Send", command=lambda: sendreply(fullsubject, toemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
944 tolabel.place(x=5, y=5)
945 subjectlabel.place(x=5, y=25)
946 bodylabel.place(x=5, y=45)
947 bodyframe.place(x=5, y=65, width=590, height=300)
948 replybodyinput.pack(expand=True, fill='both')
949 replyattachmentbutton.place(x=5, y=370)
950 replyattachmentlabel.place(x=50, y=370)
951 replyformsubmit.place(x=5, y=400)
952
953 def feedback():
954 global feedbackform
955 feedbackform = tk.Toplevel(root)
956 feedbackform.iconphoto(False, tk.PhotoImage(file=photofile))
957 feedbackform.minsize(600, 389)
958 feedbackform.maxsize(600, 389)
959 feedbackform.resizable(False, False)
960 feedbackform.configure(bg=global_bg_color)
961 global feedbackbodyinput
962 global feedbackattachment
963 feedbackattachment = ''
964 global feedbackattachmentname
965 global feedbackattachmentvar
966 feedbackattachmentvar = tk.StringVar()
967 feedbackattachmentvar.set("")
968 def faddattachment():
969 global feedbackattachment
970 global feedbackattachmentname
971 global feedbackattachmentvar
972 filepath = filedialog.askopenfilename(parent=composeform, filetypes=[('All Files', '*'), ('Text Files', '.txt'), ('Image Files', '.png .jpg'), ('Python Files', '.py .pyw')], title='Open File to Attach')
973 file = open(filepath, 'rb')
974 filetext = file.read().decode('latin1')
975 if len(filetext) > 50000:
976 messagebox.showinfo("Cannot load attachment", "We cannot load attachments over 50 KB. Please upload a different file.")
977 else:
978 feedbackattachmentname = os.path.basename(filepath)
979 feedbackattachmentvar.set(feedbackattachmentname)
980 feedbackattachment = feedbackattachmentname + "<Name Conts>" + filetext
981 bodylabel = tk.Label(feedbackform, text="Tell us what's on your mind!", justify="left", bg=global_bg_color)
982 bodyframe = tk.Frame(feedbackform, bd=1, relief='solid')
983 feedbackbodyinput = tk.Text(bodyframe, font='TkDefaultFont', bd=0)
984 attachmentbutton = tk.Button(feedbackform, text="Attach", command=faddattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
985 attachmentlabel = tk.Label(feedbackform, textvar=feedbackattachmentvar, justify="left", bg=global_bg_color)
986 feedbackformsubmit = tk.Button(feedbackform, text="Send", command=sendfeedback, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
987 bodylabel.place(x=5, y=5)
988 bodyframe.place(x=5, y=25, width=590, height=300)
989 feedbackbodyinput.pack(expand=True, fill='both')
990 attachmentbutton.place(x=5, y=330)
991 attachmentlabel.place(x=50, y=330)
992 feedbackformsubmit.place(x=5, y=360)
993
994 def sendemail():
995 update_sheets()
996 toemail = tk.StringVar()
997 subject = tk.StringVar()
998 text = tk.StringVar()
999 toemail.set(toinput.get())
1000 subject.set(subjectinput.get())
1001 text.set(bodyinput.get("1.0", "end"))
1002 composeform.destroy()
1003 row = [toemail.get(), uname, subject.get(), text.get(), attachment, 'F']
1004 emailsheet.insert_row(row, 2)
1005 toaccount = getrow("Address", toemail.get(), 'account')
1006 if toaccount == None:
1007 messagebox.showinfo("Email sent", "Successfully sent email to " + toemail.get())
1008 else:
1009 messagebox.showinfo("Email sent", "Successfully sent email to " + python_accountsheet[toaccount]["Name"] + " (" + toemail.get() + ")")
1010
1011 def sendfeedback():
1012 update_sheets()
1013 text = tk.StringVar()
1014 text.set(feedbackbodyinput.get("1.0", "end"))
1015 feedbackform.destroy()
1016 row = ['Techpad@techmail.com', uname, 'Feedback', text.get(), feedbackattachment, 'F']
1017 emailsheet.insert_row(row, 2)
1018 messagebox.showinfo('Feedback Sent', 'We\'ve recieved your feedback! We\'ll respond if we think it\'s important.')
1019
1020 def sendreply(subject, toemail):
1021 update_sheets()
1022 text = tk.StringVar()
1023 text.set(replybodyinput.get("1.0", "end"))
1024 replyform.destroy()
1025 row = [toemail, uname, subject, text.get(), replyattachment, 'F']
1026 emailsheet.insert_row(row, 2)
1027 toaccount = getrow('Address', toemail, 'account')
1028 if toaccount == None:
1029 messagebox.showinfo("Reply sent", "Successfully sent reply to " + toemail)
1030 else:
1031 messagebox.showinfo("Reply sent", "Successfully sent reply to " + python_accountsheet[toaccount]["Name"] + " (" + toemail + ")")
1032
1033 def checkemails(): # Function to check emails
1034 global inboxtext
1035 global outboxtext
1036 global Thread
1037 global time
1038 try:
1039 try:
1040 usernamelabel.destroy()
1041 except:
1042 pass
1043 try:
1044 usernameinput.destroy()
1045 except:
1046 pass
1047 try:
1048 passwordlabel.destroy()
1049 except:
1050 pass
1051 try:
1052 passwordinput.destroy()
1053 except:
1054 pass
1055 try:
1056 loginformsubmit.destroy()
1057 except:
1058 pass
1059 try:
1060 newusernamelabel.destroy()
1061 except:
1062 pass
1063 try:
1064 newusernameinput.destroy()
1065 except:
1066 pass
1067 try:
1068 namelabel.destroy()
1069 except:
1070 pass
1071 try:
1072 nameinput.destroy()
1073 except:
1074 pass
1075 try:
1076 newpasswordlabel.destroy()
1077 except:
1078 pass
1079 try:
1080 newpasswordinput.destroy()
1081 except:
1082 pass
1083 try:
1084 verifypasswordlabel.destroy()
1085 except:
1086 pass
1087 try:
1088 verifypasswordinput.destroy()
1089 except:
1090 pass
1091 try:
1092 signupformsubmit.destroy()
1093 except:
1094 pass
1095 try:
1096 loginsignupbutton.destroy()
1097 except:
1098 pass
1099 try:
1100 signuploginbutton.destroy()
1101 except:
1102 pass
1103 except:
1104 pass
1105 def whileloading():
1106 update_sheets()
1107 root_0.update()
1108 global maincanvas
1109 global parentframe
1110 parentframe = tk.Frame(root_0, bd=0, bg='white')
1111 maincanvas = tk.Canvas(parentframe, bg='white', highlightthickness=0)
1112 scrollbar = tk.Scrollbar(parentframe, orient="vertical", command=maincanvas.yview)
1113 mainframe = tk.Frame(maincanvas, bg='white')
1114 mainframe.bind(
1115 "<Configure>",
1116 lambda e: maincanvas.configure(
1117 scrollregion=maincanvas.bbox("all")
1118 )
1119 )
1120 maincanvas.create_window((0, 0), window=mainframe, anchor="nw", tags=["window1"], width=675)
1121 maincanvas.configure(yscrollcommand=scrollbar.set)
1122 def _on_mousewheel(event):
1123 maincanvas.yview_scroll(int(-1 * (event.delta / 120)), "units")
1124 maincanvas.bind_all("<MouseWheel>", _on_mousewheel)
1125 inboxrows = getrow("To", uname, 'email') # Get rows of emails that were sent to the user
1126 sentrows = getrow("From", uname, 'email') # Get rows of emails that were sent by the user
1127 emailnumber = 1 # Used later
1128 inboxtext = tk.StringVar()
1129 if inboxrows == []:
1130 aminem = "0"
1131 else:
1132 aminem = str(len(inboxrows))
1133 if sentrows == []:
1134 amseem = "0"
1135 else:
1136 amseem = str(len(sentrows))
1137 inboxtext.set("\n\n\u2014\u2014\u2014 Inbox (" + aminem + ") \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n")
1138 inboxlabel = tk.Label(mainframe, textvar=inboxtext, justify="left", padx=50, bg=global_bg_color)
1139 inboxlabel.pack(side='top', anchor='nw')
1140 outboxtext = tk.StringVar()
1141 outboxtext.set("\n\u2014\u2014\u2014 Sent (" + amseem + ") \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n")
1142 if inboxrows == []: # If there are no emails to display
1143 inboxtext.set(inboxtext.get() + "There are no emails in your inbox.")
1144 else: # If there are emails to display
1145 for element in inboxrows: # For loop to display inbox
1146 readt = python_emailsheet[element]["Read"]
1147 if readt == 'F':
1148 read = False
1149 elif readt == 'T':
1150 read = True
1151 sentfrom = python_emailsheet[element]["From"]
1152 subject = python_emailsheet[element]["Subject"]
1153 text = python_emailsheet[element]["Text"]
1154 fromaccount = getrow("Address", sentfrom, "account")
1155 if fromaccount == None:
1156 fromname = "Unknown"
1157 else:
1158 fromname = python_accountsheet[fromaccount]["Name"]
1159 if text[-1] == '\n':
1160 text = text[:-1]
1161 if len(text) > 25:
1162 text = text[:25] + "..."
1163 if "\n" in text:
1164 text = text.partition("\n")[0] + "..."
1165 emailbuttontext = "\u2014 " + fromname + " (" + sentfrom + ")\n Subject: " + subject + "\n \"" + text + "\""
1166 emailbutton = tk.Button(mainframe, text=emailbuttontext, command=lambda emn=emailnumber: inboxnew(emn), bg='white', activebackground='#ddeeff', bd=0, relief='solid', cursor='hand2', justify='left', padx=50, anchor='w', wraplength=550)
1167 if read == False:
1168 emailbutton.config(font='TkDefaultFont 9 bold')
1169 else:
1170 pass
1171 emailbutton.pack(expand=True, fill='x')
1172 emailnumber += 1
1173 outboxlabel = tk.Label(mainframe, textvar=outboxtext, justify="left", padx=50, bg=global_bg_color)
1174 outboxlabel.pack(side="top", anchor="nw")
1175 if sentrows == []:
1176 outboxtext.set(outboxtext.get() + "You have not sent any emails.")
1177 else:
1178 emailnumber = 1
1179 for element in sentrows:
1180 sentto = python_emailsheet[element]["To"]
1181 subject = python_emailsheet[element]["Subject"]
1182 text = python_emailsheet[element]["Text"]
1183 toaccount = getrow("Address", sentto, "account")
1184 if toaccount == None:
1185 toname = "Unknown"
1186 else:
1187 toname = python_accountsheet[toaccount]["Name"]
1188 if text[-1] == '\n':
1189 text = text[:-1]
1190 if len(text) > 25:
1191 text = text[:25] + "..."
1192 if "\n" in text:
1193 text = text.partition("\n")[0] + "..."
1194 emailbuttontext = "\u2014 Me, " + toname + " (" + sentto + ")\n Subject: " + subject + "\n \"" + text + "\""
1195 emailbutton = tk.Button(mainframe, text=emailbuttontext, command=lambda emn=emailnumber: outboxnew(emn), bg='white', activebackground='#ddeeff', bd=0, relief='solid', cursor='hand2', justify='left', padx=50, anchor='w', wraplength=550)
1196 emailbutton.pack(expand=True, fill='x')
1197 emailnumber += 1
1198 readabilityspacer = tk.Label(mainframe, text='\n\n\n', bg='white')
1199 readabilityspacer.pack()
1200 #showinboxbutton = tk.Button(parentframe, text="Show inbox email", command=inbox, bg='white', bd=1, relief='solid',
1201 # activebackground='#ddeeff')
1202 #showoutboxbutton = tk.Button(parentframe, text="Show sent email", command=outbox, bg='white', bd=1, relief='solid',
1203 # activebackground='#ddeeff')
1204 composebutton = tk.Button(parentframe, text="Compose", command=compose, bg='white', bd=1, relief='solid',
1205 activebackground='#ddeeff', cursor='hand2')
1206 refreshbutton = tk.Button(parentframe, text="Refresh", command=refreshemails, bg='white', bd=1, relief='solid',
1207 activebackground='#ddeeff', cursor='hand2')
1208 logoutbutton = tk.Button(parentframe, text="Logout", command=logout, bg='white', bd=1, relief='solid',
1209 activebackground='#ddeeff', cursor='hand2')
1210 accountbutton = tk.Button(parentframe, text="Account", command=account, bg='white', bd=1, relief='solid',
1211 activebackground='#ddeeff', cursor='hand2')
1212 helpbutton = tk.Button(parentframe, text="Help", command=help, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
1213 feedbackbutton = tk.Button(parentframe, text="Feedback", command=feedback, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
1214 #showinboxbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1215 #showoutboxbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1216 composebutton.pack(side='left', anchor='sw', padx=5, pady=5)
1217 refreshbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1218 logoutbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1219 accountbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1220 helpbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1221 feedbackbutton.pack(side='left', anchor='sw', padx=5, pady=5)
1222 parentframe.pack(expand=True, fill="both")
1223 maincanvas.place(x=0, y=0, relwidth=1.0, relheight=1.0)
1224 scrollbar.pack(side="right", fill="y")
1225 global isloading
1226 isloading = 'false'
1227 loadingthread = Thread(target=whileloading, daemon=True)
1228 loadingthread.start()
1229 def loadingscreen():
1230 global isloading
1231 global time
1232 isloading = 'true'
1233 frames = [tk.PhotoImage(file=loadingimage, format='gif -index %i' % (i)) for i in
1234 range(20)]
1235 def update(ind, numreps, ttf):
1236 global time
1237 if isloading == 'true':
1238 frame = frames[ind]
1239 if ind < 19:
1240 ind += 1
1241 elif ind == 19:
1242 ind = 0
1243 numreps += 1
1244 if numreps == 500:
1245 messagebox.showinfo("Possible loading error", "TechMail is taking a long time to load. If you do not have a lot of emails to load, try restarting TechMail and trying again.")
1246 loadinglabel.configure(image=frame)
1247 if ttf < 50:
1248 ttf += 1
1249 elif ttf == 50:
1250 tip = random.choice(tips)
1251 tiplabel.configure(text=tip)
1252 ttf = 0
1253 root_0.update()
1254 time.sleep(0.05)
1255 update(ind, numreps, ttf)
1256 else:
1257 loadinglabel.destroy()
1258 tiplabel.destroy()
1259 loadinglabel = tk.Label(root_0, bg=global_bg_color, anchor='center')
1260 loadinglabel.place(relwidth=1.0, relheight=1.0)
1261 tiplabel = tk.Label(root_0, bg=global_bg_color, anchor='n', text='Loading...', wraplength=300, pady=20, font='Quicksand 10')
1262 tiplabel.pack()
1263 root_0.after(0, update, 0, 0, 50)
1264 root_0.update()
1265 loadingscreenthread = Thread(target=loadingscreen, daemon=True)
1266 loadingscreenthread.start()
1267
1268 def refreshemails():
1269 parentframe.destroy()
1270 #inboxlabel.destroy()
1271 #outboxlabel.destroy()
1272 #showinboxbutton.destroy()
1273 #showoutboxbutton.destroy()
1274 #composebutton.destroy()
1275 #refreshbutton.destroy()
1276 #logoutbutton.destroy()
1277 #accountbutton.destroy()
1278 #helpbutton.destroy()
1279 checkemails()
1280
1281 def logout():
1282 uname = 'Guest'
1283 rname = 'Guest'
1284 try:
1285 mainframe.destroy()
1286 except:
1287 pass
1288 try:
1289 maincanvas.destroy()
1290 except:
1291 pass
1292 try:
1293 parentframe.destroy()
1294 except:
1295 pass
1296 try:
1297 signuploginbutton.destroy()
1298 except:
1299 pass
1300 startup()
1301
1302 def yeet():
1303 yeetcode = """import tkinter as tk
1304import random
1305stuff = frame1
1306eastereggtips = """ + str(eastereggtips) + """
1307yeetl = tk.Label(stuff, text='Stuff', font='Quicksand 25', pady=20, bg=global_bg_color, fg='dodgerblue', padx=5)
1308yeetl.pack(side='top', anchor='nw')
1309def rickroll(e):
1310 os.system('start https://www.youtube.com/watch?v=DLzxrzFCyOs')
1311meme = random.choice(eastereggtips)
1312if meme == "Click here for an egg salad subcontrabass piccolo dish":
1313 memebutton = tk.Label(stuff, text=meme, padx=5, bg=global_bg_color, wraplength=590, justify='left')
1314 memebutton.bind('<Button-1>', rickroll)
1315 memebutton.pack(side='top', anchor='nw')
1316else:
1317 memelabel = tk.Label(stuff, text=meme, padx=5, bg=global_bg_color, wraplength=590, justify='left')
1318 memelabel.pack(side='top', anchor='nw')"""
1319 yeetwindow = create_window(width=400, height=300, title='Stuff', img='T:/Programs/TechMail/Attributes/Icon.png', code=yeetcode)
1320
1321 def startup(): # On startup, do this
1322 global logolabel
1323 global versionlabel
1324 try:
1325 logolabel.destroy()
1326 versionlabel.destroy()
1327 except:
1328 pass
1329 global titlelabel
1330 titlelabel = tk.Label(root_0, text='\nTechMail', image=largeicon, font='Quicksand 40', pady=15, bg=global_bg_color, fg='dodgerblue')
1331 titlelabel.pack(pady=50)
1332 global loginbutton
1333 loginbutton = tk.Button(root_0, bg='white', bd=0, relief='solid', activebackground='white', image=loginbuttonimage, cursor='hand2')
1334 def loginbuttonpressed(e):
1335 loginbutton.config(image=loginpressedimage)
1336 return "break"
1337 def loginbuttonreleased(e):
1338 loginbutton.config(image=loginbuttonimage)
1339 x, y = root_0.winfo_pointerxy()
1340 widget = root_0.winfo_containing(x, y)
1341 if widget == loginbutton:
1342 login()
1343 else:
1344 pass
1345 loginbutton.bind("<Button-1>", loginbuttonpressed)
1346 loginbutton.bind("<ButtonRelease-1>", loginbuttonreleased)
1347 loginbutton.pack()
1348 global spacer
1349 spacer = tk.Label(root_0, text='', bg=global_bg_color)
1350 spacer.pack()
1351 global signupbutton
1352 signupbutton = tk.Button(root_0, bg='white', bd=0, relief='solid', activebackground='white', image=signupbuttonimage, cursor='hand2', command=yeet)
1353 def signupbuttonpressed(e):
1354 signupbutton.config(image=signuppressedimage)
1355 return "break"
1356 def signupbuttonreleased(e):
1357 signupbutton.config(image=signupbuttonimage)
1358 x, y = root_0.winfo_pointerxy()
1359 widget = root_0.winfo_containing(x, y)
1360 if widget == signupbutton:
1361 signup()
1362 else:
1363 pass
1364 signupbutton.bind("<Button-1>", signupbuttonpressed)
1365 signupbutton.bind("<ButtonRelease-1>", signupbuttonreleased)
1366 signupbutton.pack()
1367
1368 startup() # Run startup function
1369
1370startupthread = Thread(target=runprogram, daemon=True)
1371startupthread.start()