Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import ast
- from tkinter import messagebox, simpledialog, filedialog
- import sys
- import os
- from threading import Thread
- import time
- try:
- import gspread
- except ModuleNotFoundError:
- os.system("pip install gspread")
- import gspread
- try:
- from oauth2client.service_account import ServiceAccountCredentials
- except ModuleNotFoundError:
- os.system('pip install oauth2client')
- from oauth2client.service_account import ServiceAccountCredentials
- try:
- import getpass
- except ModuleNotFoundError:
- os.system("pip install getpass")
- import getpass
- try:
- import random
- except ModuleNotFoundError:
- os.system('pip install random')
- import random
- try:
- import pyglet as tpg
- except ModuleNotFoundError:
- os.system('pip install pyglet')
- import pyglet as tpg
- sys.setrecursionlimit(10**6)
- tmversion = 'TechMail TechOSV pre00.07_04'
- global root_0
- root_0 = frame1
- # Images
- global photofile
- photofile = os.path.join(sys.path[0], 'Attributes\Icon.png')
- photofile = 'T:/Programs/TechMail/Attributes/Icon.png'
- global logoimage
- logoimage = os.path.join(sys.path[0], 'Attributes\Techpad Logo.png')
- logoimage = 'T:/Programs/TechMail/Attributes/Techpad Logo.png'
- logophoto = tk.PhotoImage(file=logoimage)
- global loadingimage
- loadingimage = os.path.join(sys.path[0], 'Attributes\Loading.gif')
- loadingimage = 'T:/Programs/TechMail/Attributes/Loading.gif'
- global largeicon
- largeiconfile = os.path.join(sys.path[0], 'Attributes\Large Icon v2.png')
- largeiconfile = 'T:/Programs/TechMail/Attributes/Large Icon v2.png'
- largeicon = tk.PhotoImage(file=largeiconfile)
- global loginbuttonimage
- loginbuttonfile = os.path.join(sys.path[0], 'Attributes\LoginButton.png')
- loginbuttonfile = 'T:/Programs/TechMail/Attributes/LoginButton.png'
- loginbuttonimage = tk.PhotoImage(file=loginbuttonfile)
- global loginpressedimage
- loginpressedfile = os.path.join(sys.path[0], 'Attributes\LoginButtonPressed.png')
- loginpressedfile = 'T:/Programs/TechMail/Attributes/LoginButtonPressed.png'
- loginpressedimage = tk.PhotoImage(file=loginpressedfile)
- global signupbuttonimage
- signupbuttonfile = os.path.join(sys.path[0], 'Attributes\SignupButton.png')
- signupbuttonfile = 'T:/Programs/TechMail/Attributes/SignupButton.png'
- signupbuttonimage = tk.PhotoImage(file=signupbuttonfile)
- global signuppressedimage
- signuppressedfile = os.path.join(sys.path[0], 'Attributes\SignupButtonPressed.png')
- signuppressedfile = 'T:/Programs/TechMail/Attributes/SignupButtonPressed.png'
- signuppressedimage = tk.PhotoImage(file=signuppressedfile)
- logolabel = tk.Label(root_0, bg='white', anchor='center')
- logolabel.image = logophoto
- logolabel.config(image=logolabel.image)
- logolabel.place(relwidth=1.0, relheight=1.0)
- versionlabel = tk.Label(root_0, text=tmversion, bg='white', anchor='center', font='arial 10')
- versionlabel.pack(side='bottom', pady=50, anchor='s')
- def runprogram():
- global ast, messagebox, simpledialog, filedialog, tk, os, sys, gspread, ServiceAccountCredentials, getpass, random, tpg, root_0, Thread, time
- # Scope for Google Drive API
- scope = [
- 'https://www.googleapis.com/auth/drive',
- 'https://www.googleapis.com/auth/drive.file'
- ]
- # File for login key
- file_name = os.path.join(sys.path[0], 'API\client_key.json')
- # Experimental Files
- file_name = 'T:/Programs/TechMail/API/client_key.json'
- # Login
- creds = ServiceAccountCredentials.from_json_keyfile_name(file_name, scope)
- client = gspread.authorize(creds)
- global python_emailsheet
- global python_accountsheet
- # Open Spreadsheets
- try:
- emailsheet = client.open('TechMail Emails').sheet1
- python_emailsheet = emailsheet.get_all_records()
- accountsheet = client.open('TechMail Accounts').sheet1
- python_accountsheet = accountsheet.get_all_records()
- except gspread.exceptions.APIError:
- messagebox.showinfo('Server Error', 'The TechMail servers are experiencing high traffic. We will try loading again when they are back online.')
- time.sleep(100)
- try:
- emailsheet = client.open('TechMail Emails').sheet1
- python_emailsheet = emailsheet.get_all_records()
- accountsheet = client.open('TechMail Accounts').sheet1
- python_accountsheet = accountsheet.get_all_records()
- except gspread.exceptions.APIError:
- messagebox.showinfo('Server Error',
- 'The TechMail servers are still experiencing high traffic. Please try again later.')
- sys.exit()
- root_0.destroy()
- except:
- messagebox.showinfo("Client Error", "Your internet seems to be having trouble. Check for any apps that might be using up your resources.")
- fontfile = os.path.join(sys.path[0], 'Attributes\TMFont.ttf')
- fontfile = 'T:/Programs/TechMail/Attributes/TMFont.ttf'
- tpg.font.add_file(fontfile)
- global tpcreds
- global uname
- global rname
- # Get Techpad Credentials
- try:
- tpcredsfile = open('C:/Program Files/Techpad/Techpad Credentials/Creds.stpc', 'r')
- tpcredsfull = tpcredsfile.read()
- tpcredstext = tpcredsfull[8:]
- tpcreds = ast.literal_eval(tpcredstext)
- tpcredsfile.close()
- except:
- tpcreds = [0]
- # Make temporary user variables
- uname = "Guest"
- rname = "Guest"
- # Tips & tricks
- tips = [
- "Press refresh to see new emails!",
- "Press logout to switch accounts!",
- "You can send up to one attachment per email.",
- "An email attachment can be no more than 50 KB.",
- "You can't hack Techpad ¯\_(?)_/¯",
- "Email Techpad at Techpad@techmail.com if you have questions or feedback!",
- "Read the changelog to see what's new!",
- "TechMail has no easter eggs. At least, none that we know of.",
- "Use the reply button in an email for a quick way to reply!",
- "More features coming soon!",
- "TechMail is written in Python!",
- "If the email preview is bold, it means you haven't read it yet.",
- "You can access previous versions of TechMail in the Versions folder (as long as they're stable.)",
- "Yeet!",
- "TechMail uses multithreaded processing!",
- "Does anybody care about these tips?",
- "You can't delete emails... yet.",
- "You need internet for TechMail to work.",
- "Don't look at the console! There's nothing important there.",
- "If you used the installer, TechMail is on your home screen!",
- "You can make your TechMail address whatever you want!",
- "Anyone can see your name! Be careful.",
- "Make sure you use a good password!",
- "Did you know? The first versions of TechMail were console based!",
- "Check out some other Techpad apps!",
- "New emails appear on top!",
- "Over 1,000 lines of code!"
- ]
- eastereggtips = [
- "If you have 666 emails in your inbox, then they will all say yeet",
- "Big Chungus likes potatoes",
- "TechMail has over 100 useless lines of code",
- "Earth is a ravioli",
- "Life is a hallucination caused by breathing. Once you stop breathing, the hallucination ends",
- "The point of golf is to play as little golf as possible",
- "You can breathe underwater if you'ree smart enough",
- "Whatever you do, do not enjoy Yeeting Simulator. It sucks",
- "Whatever you do, do NOT eat the free pistachio ice cream. It has TURNED.",
- "Moo",
- "Bruh",
- "Fun fact: At least 5 people live in Australia",
- "Everyone who has come into contact with water will die",
- """Never gonna give you up
- Never gonna let you down
- Never gonna run around and desert you
- Never gonna make you cry
- Never gonna say goodbye
- Never gonna tell a lie and hurt you""",
- "Disco Fish",
- "Disco Shrek",
- "Yeet",
- "Fun fact: If you stab yourself, you'll bleed",
- "The sunglasses ate your coffee",
- "Click here for an egg salad subcontrabass piccolo dish"
- ]
- global global_bg_color
- global_bg_color = 'white'
- def update_sheets():
- global python_emailsheet
- global python_accountsheet
- python_emailsheet = emailsheet.get_all_records()
- python_accountsheet = accountsheet.get_all_records()
- # Function to find row based on text in column
- def getrow(col, text, sheet):
- if sheet == 'account': # For finding account information
- row = 0
- for element in python_accountsheet:
- if element[col] == text:
- return row
- break
- else:
- row += 1
- else:
- return None
- elif sheet == 'email': # For finding emails based on account
- row = 0
- matchingrows = []
- for element in python_emailsheet:
- if element[col] == text:
- matchingrows.append(row)
- row += 1
- else:
- row += 1
- return matchingrows
- def signup(): # Function to make an account
- try:
- titlelabel.destroy()
- loginbutton.destroy()
- spacer.destroy()
- signupbutton.destroy()
- except:
- pass
- global newusernamelabel
- newusernamelabel = tk.Label(root_0, text="Create a TechMail Address (@techmail.com)", justify="left", bg=global_bg_color, font='Quicksand 10')
- global namelabel
- namelabel = tk.Label(root_0, text="Name", justify="left", bg=global_bg_color, font='Quicksand 10')
- global newpasswordlabel
- newpasswordlabel = tk.Label(root_0, text="Create a Password", justify="left", bg=global_bg_color, font='Quicksand 10')
- global verifypasswordlabel
- verifypasswordlabel = tk.Label(root_0, text="Verify your Password", justify="left", bg=global_bg_color, font='Quicksand 10')
- global newusernameinput
- newusernameinput = tk.Entry(root_0, width=30, bd=1, relief='solid', font='Quicksand 10')
- global nameinput
- nameinput = tk.Entry(root_0, width=30, bd=1, relief='solid', font='Quicksand 10')
- global newpasswordinput
- newpasswordinput = tk.Entry(root_0, width=30, bd=1, relief='solid', show='\u2022', font='Quicksand 10')
- global verifypasswordinput
- verifypasswordinput = tk.Entry(root_0, width=30, bd=1, relief='solid', show='\u2022', font='Quicksand 10')
- global signupformsubmit
- signupformsubmit = tk.Button(root_0, text="Sign up", command=evaluatesignup, bg='white', bd=1, relief='solid', activebackground='#ddeeff', font='Quicksand 10', cursor='hand2')
- global signuploginbutton
- 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')
- newusernamelabel.place(x=5, y=5)
- newusernameinput.place(x=5, y=25)
- namelabel.place(x=5, y=45)
- nameinput.place(x=5, y=65)
- newpasswordlabel.place(x=5, y=85)
- newpasswordinput.place(x=5, y=105)
- verifypasswordlabel.place(x=5, y=125)
- verifypasswordinput.place(x=5, y=145)
- signupformsubmit.place(x=5, y=175)
- signuploginbutton.place(x=5, y=210)
- def evaluatesignup():
- newusername = newusernameinput.get()
- newpassword = newpasswordinput.get()
- verifypassword = verifypasswordinput.get()
- name = nameinput.get()
- if newpassword == verifypassword:
- global python_emailsheet
- global python_accountsheet
- update_sheets()
- rownumber = len(python_accountsheet) + 2 # Get how many rows there are and add 1
- emailrownumber = len(python_emailsheet) + 2
- row = [newusername, name, newpassword] # Row to add
- body = "A new account has been made. Check for spam.\nTechMail Address: " + newusername + "\nName: " + name + "\nPassword: " + newpassword
- emailrow = ["Techpad@techmail.com", "TechMailActivity@techmail.com", "New Account Made", body]
- accountsheet.insert_row(row, rownumber) # Add the row
- emailsheet.insert_row(emailrow, emailrownumber)
- messagebox.showinfo("Signup Successful",
- "Your account has been successfully created. You will need to log in again.")
- uname = newusername
- rname = name
- newusernamelabel.destroy()
- namelabel.destroy()
- newpasswordlabel.destroy()
- verifypasswordlabel.destroy()
- newusernameinput.destroy()
- nameinput.destroy()
- newpasswordinput.destroy()
- verifypasswordinput.destroy()
- signupformsubmit.destroy()
- logout()
- else:
- messagebox.showinfo("Passwords do not match", "Your passwords do not match. Please try again.")
- def loginsignup():
- usernamelabel.destroy()
- passwordlabel.destroy()
- usernameinput.destroy()
- passwordinput.destroy()
- loginformsubmit.destroy()
- loginsignupbutton.destroy()
- signup()
- def signuplogin():
- newusernamelabel.destroy()
- namelabel.destroy()
- newpasswordlabel.destroy()
- verifypasswordlabel.destroy()
- newusernameinput.destroy()
- nameinput.destroy()
- newpasswordinput.destroy()
- verifypasswordinput.destroy()
- signupformsubmit.destroy()
- signuploginbutton.destroy()
- login()
- def login(): # Function to login
- try:
- titlelabel.destroy()
- loginbutton.destroy()
- spacer.destroy()
- signupbutton.destroy()
- except:
- pass
- global usernamelabel
- usernamelabel = tk.Label(root_0, text="TechMail Address", justify="left", bg=global_bg_color, font='Quicksand 10')
- global passwordlabel
- passwordlabel = tk.Label(root_0, text="Password", justify="left", bg=global_bg_color, font='Quicksand 10')
- global usernameinput
- usernameinput = tk.Entry(root_0, width=30, bd=1, relief='solid', font='Quicksand 10')
- global passwordinput
- passwordinput = tk.Entry(root_0, width=30, bd=1, relief='solid', show='\u2022', font='Quicksand 10')
- global loginformsubmit
- loginformsubmit = tk.Button(root_0, text="Login", command=evaluatelogin, bg='white', bd=1, relief='solid', activebackground='#ddeeff', font='Quicksand 10', cursor='hand2')
- global loginsignupbutton
- 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')
- usernamelabel.place(x=5, y=5)
- usernameinput.place(x=5, y=25)
- passwordlabel.place(x=5, y=45)
- passwordinput.place(x=5, y=65)
- loginformsubmit.place(x=5, y=95)
- loginsignupbutton.place(x=5, y=130)
- def evaluatelogin():
- global uname
- global rname
- global python_emailsheet
- global python_accountsheet
- username = usernameinput.get()
- password = passwordinput.get()
- musername = getrow("Address", username, "account")
- if musername == None: # If it is not
- messagebox.showinfo("Invalid TechMail Address",
- "The TechMail Address you entered is invalid. Please try again.")
- else: # If valid TechMail Address, ask for password
- if username == 'Techpad@techmail.com':
- index = 0
- if not len(tpcreds) == 1:
- for element in tpcreds:
- if element == 'Techpad':
- nextindex = index + 1
- if tpcreds[nextindex] == 'N#hrnvHN*&@3hrnHND98Nr9':
- uname = 'Techpad@techmail.com'
- rname = 'Techpad'
- checkemails()
- break
- else:
- messagebox.showinfo("Access Denied",
- "You do not have access to that account. Please try again.")
- break
- else:
- index += 1
- else:
- messagebox.showinfo("Access Denied",
- "You do not have access to that account. Please try again.")
- else:
- messagebox.showinfo("Access Denied", "You do not have access to that account. Please try again.")
- elif username == 'TechMailActivity@techmail.com':
- index = 0
- if not len(tpcreds) == 1:
- for element in tpcreds:
- if element == 'TechMailActivity':
- nextindex = index + 1
- if tpcreds[nextindex] == '(*m(8hdfm^f%SVf56B0nf*&GWf':
- uname = 'TechMailActivity@techmail.com'
- rname = 'TechMail Activity'
- checkemails()
- break
- else:
- messagebox.showinfo("Access Denied",
- "You do not have access to that account. Please try again.")
- break
- else:
- index += 1
- else:
- messagebox.showinfo("Access Denied",
- "You do not have access to that account. Please try again.")
- else:
- messagebox.showinfo("Access Denied", "You do not have access to that account. Please try again.")
- elif username == 'Techpjm@techmail.com':
- index = 0
- if not len(tpcreds) == 1:
- for element in tpcreds:
- if element == 'TechPJM':
- nextindex = index + 1
- if tpcreds[nextindex] == 'NV#rn7E(D*F83r*F((Sd9f388NE':
- uname = 'Techpjm@techmail.com'
- rname = 'TechPJM'
- checkemails()
- break
- else:
- messagebox.showinfo("Access Denied",
- "You do not have access to that account. Please try again.")
- break
- else:
- index += 1
- else:
- messagebox.showinfo("Access Denied",
- "You do not have access to that account. Please try again.")
- else:
- messagebox.showinfo("Access Denied", "You do not have access to that account. Please try again.")
- else:
- update_sheets()
- truepassword = python_accountsheet[musername]["Password"]
- if password == truepassword: # Compare passwords
- name = python_accountsheet[musername]["Name"] # Get name
- username = python_accountsheet[musername]["Address"] # Get username
- uname = username # Set username variable
- rname = name # Set real name variable
- checkemails() # Start using TechMail
- else: # If passwords do not match
- messagebox.showinfo("Password Incorrect",
- "The password you entered did not match the username. Please try again.")
- # def settings(): - Does not work well currently
- # global global_bg_color
- # settings = tk.Toplevel(root_0)
- # settings.title("Settings - TechMail")
- # settings.iconphoto(False, tk.PhotoImage(file=photofile))
- # settings.minsize(400, 300)
- # settings.maxsize(400, 300)
- # settings.resizable(False, False)
- # settings.configure(bg=global_bg_color)
- # settingslabel = tk.Label(settings, text='Settings', font='Quicksand 40', pady=20, bg='white', fg='dodgerblue')
- # settingslabel.pack(anchor='nw')
- # bgcolorname = tk.StringVar()
- # if global_bg_color == 'white':
- # bgcolorname.set('White')
- # elif global_bg_color == 'lightgray':
- # bgcolorname.set('Light Gray')
- # elif global_bg_color == '#ffcccc':
- # bgcolorname.set('Red')
- # elif global_bg_color == '#ffeecc':
- # bgcolorname.set('Orange')
- # elif global_bg_color == '#ffffcc':
- # bgcolorname.set('Yellow')
- # elif global_bg_color == '#ccffcc':
- # bgcolorname.set('Green')
- # elif global_bg_color == '#ddeeff':
- # bgcolorname.set('Light Blue')
- # elif global_bg_color == '#ccccff':
- # bgcolorname.set('Blue')
- # elif global_bg_color == '#ffccff':
- # bgcolorname.set('Purple')
- # def changebg():
- # global global_bg_color
- # if global_bg_color == 'white':
- # global_bg_color = 'lightgray'
- # elif global_bg_color == 'lightgray':
- # global_bg_color = '#ffcccc'
- # elif global_bg_color == '#ffcccc':
- # global_bg_color = '#ffeecc'
- # elif global_bg_color == '#ffeecc':
- # global_bg_color = '#ffffcc'
- # elif global_bg_color == '#ffffcc':
- # global_bg_color = '#ccffcc'
- # elif global_bg_color == '#ccffcc':
- # global_bg_color = '#ddeeff'
- # elif global_bg_color == '#ddeeff':
- # global_bg_color = '#ccccff'
- # elif global_bg_color == '#ccccff':
- # global_bg_color = '#ffccff'
- # elif global_bg_color == '#ffccff':
- # global_bg_color = 'white'
- # if global_bg_color == 'white':
- # bgcolorname.set('White')
- # elif global_bg_color == 'lightgray':
- # bgcolorname.set('Light Gray')
- # elif global_bg_color == '#ffcccc':
- # bgcolorname.set('Red')
- # elif global_bg_color == '#ffeecc':
- # bgcolorname.set('Orange')
- # elif global_bg_color == '#ffffcc':
- # bgcolorname.set('Yellow')
- # elif global_bg_color == '#ccffcc':
- # bgcolorname.set('Green')
- # elif global_bg_color == '#ddeeff':
- # bgcolorname.set('Light Blue')
- # elif global_bg_color == '#ccccff':
- # bgcolorname.set('Blue')
- # elif global_bg_color == '#ffccff':
- # bgcolorname.set('Purple')
- # root_0.configure(bg=global_bg_color)
- # changebgbutton = tk.Button(settings, textvar=bgcolorname, font='Quicksand 15', padx=5, pady=5, command=changebg, bg='white', bd=1, relief='solid', activebackground='#ddeeff')
- # changebgbutton.pack(anchor='nw', padx=5)
- def character_limit(entry_text):
- if len(entry_text.get()) > 24:
- entry_text.set(entry_text.get()[:24])
- def help():
- helpwcode = """import tkinter as tk
- helpw = frame1
- helplabel = tk.Label(helpw, text='Help', font='Quicksand 25', pady=20, bg='white', fg='dodgerblue', padx=5)
- helplabel.pack(side='top', anchor='nw')
- helpinfotext = '''- 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\".'''
- helpinfo = tk.Label(helpw, text=helpinfotext, padx=5, bg='white', wraplength=590, justify='left')
- helpinfo.pack(side='top', anchor='nw')"""
- helpwindow = create_window(x=150, y=150, width=600, height=400, img='T:/Programs/TechMail/Attributes/Icon.png', title='Help - TechMail', code=helpwcode)
- def account():
- update_sheets()
- accountw = tk.Toplevel(root)
- accountw.title('Account - TechMail')
- accountw.configure(bg=global_bg_color)
- accountw.minsize(600, 400)
- accountw.maxsize(600, 400)
- accountw.resizable(False, False)
- accountw.iconphoto(False, tk.PhotoImage(file=photofile))
- def changeaccinfo():
- update_sheets()
- accountrow = getrow("Address", uname, 'account') + 2
- if accnewpasswordinput.get() == accverifypasswordinput.get():
- accountsheet.update_cell(accountrow, 2, accnameinput.get())
- accountsheet.update_cell(accountrow, 3, accnewpasswordinput.get())
- else:
- messagebox.showinfo("Passwords do not match", "Your new passwords do not match. Please try again.")
- accountlabel = tk.Label(accountw, text='Account Settings', font='Quicksand 40', pady=20, bg='white', fg='dodgerblue')
- accnewusernamelabel = tk.Label(accountw, text="TechMail Address", justify="left",
- bg=global_bg_color)
- accnamelabel = tk.Label(accountw, text="Name", justify="left", bg=global_bg_color)
- accnewpasswordlabel = tk.Label(accountw, text="Password", justify="left", bg=global_bg_color)
- accverifypasswordlabel = tk.Label(accountw, text="Verify password", justify="left", bg=global_bg_color)
- accusernameinput = tk.Label(accountw, text=uname, justify="left", bg=global_bg_color)
- accnameinput = tk.Entry(accountw, width=30, bd=1, relief='solid')
- accnewpasswordinput = tk.Entry(accountw, width=30, bd=1, relief='solid', show='\u2022')
- accverifypasswordinput = tk.Entry(accountw, width=30, bd=1, relief='solid', show='\u2022',)
- accformsubmit = tk.Button(accountw, text="Save", command=changeaccinfo, bg='white', bd=1, relief='solid',
- activebackground='#ddeeff', cursor='hand2')
- accountrow = getrow("Address", uname, 'account')
- accusernameinput.config(text=uname)
- accnameinput.insert(0, python_accountsheet[accountrow]["Name"])
- accnewpasswordinput.insert(0, python_accountsheet[accountrow]["Password"])
- accverifypasswordinput.insert(0, python_accountsheet[accountrow]["Password"])
- accountlabel.pack(side='top', anchor='nw', padx=5)
- accnewusernamelabel.pack(side='top', anchor='w', padx=5)
- accusernameinput.pack(side='top', anchor='w', padx=5)
- accnamelabel.pack(side='top', anchor='w', padx=5)
- accnameinput.pack(side='top', anchor='w', padx=5)
- accnewpasswordlabel.pack(side='top', anchor='w', padx=5)
- accnewpasswordinput.pack(side='top', anchor='w', padx=5)
- accverifypasswordlabel.pack(side='top', anchor='w', padx=5)
- accverifypasswordinput.pack(side='top', anchor='w', padx=5)
- accformsubmit.pack(side='top', anchor='sw', padx=5, pady=5)
- def inbox():
- todo = simpledialog.askstring("Inbox", "Type the number of the email in your inbox that you want to display:",
- parent=root_0)
- inboxrows = getrow(1, uname, 'email')
- if inboxrows[0] == 0:
- messagebox.showinfo("No emails", "You have no emails in your inbox.")
- else:
- email = int(todo) - 1
- try:
- emailrow = inboxrows[int(email)]
- fromemail = emailsheet.cell(emailrow, 2).value
- subject = emailsheet.cell(emailrow, 3).value
- text = emailsheet.cell(emailrow, 4).value
- global emailattachment
- emailattachment = emailsheet.cell(emailrow, 5).value
- fromaccount = getrow(1, fromemail, 'account')
- if fromaccount == 0:
- fromname = "Unknown"
- else:
- fromname = accountsheet.cell(fromaccount, 2).value
- emailmessage = tk.Toplevel(root_0)
- emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
- tovar = tk.StringVar()
- fromvar = tk.StringVar()
- subjectvar = tk.StringVar()
- bodyvar = tk.StringVar()
- emailattachmentname = tk.StringVar()
- tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
- fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
- subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
- bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
- replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, fromemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- def downloadattachment():
- global emailattachment
- downloadattachmentname = emailattachment.partition('<Name Conts>')[0]
- downloadattachmentcontents = emailattachment.partition('<Name Conts>')[2]
- downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
- if not downloadname == '':
- downloadfile = open(downloadname, 'wb')
- downloadfile.write(downloadattachmentcontents.encode('latin1'))
- downloadfile.close()
- else:
- pass
- emailmessage.minsize(600, 400)
- emailmessage.maxsize(600, 600)
- emailmessage.resizable(False, True)
- emailmessage.configure(bg=global_bg_color)
- tovar.set('To: Me (' + uname + ')')
- fromvar.set('From: ' + fromname + ' (' + fromemail + ')')
- subjectvar.set('Subject: ' + subject)
- bodyvar.set(text)
- tolabel.place(x=10, y=10)
- fromlabel.place(x=10, y=30)
- subjectlabel.place(x=10, y=50)
- bodylabel.place(x=10, y=85)
- if not emailattachment == '':
- emailattachmentname.set(emailattachment.partition('<Name Conts>')[0])
- emailattachmentbutton = tk.Button(emailmessage, textvar=emailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- emailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
- emailmessage.title(subject + ' - TechMail')
- global reademails
- emailnumber = email + 1
- if not emailnumber in reademails and not fromemail == 'TechMailActivity@techmail.com':
- reademails.append(emailnumber)
- reademailsfile = open(read_emails_file_name, "w")
- reademailsfile.write(str(reademails))
- reademailsfile.close()
- except IndexError:
- messagebox.showinfo("Email not found", "That email doesn't exist. Please try again.")
- def inboxnew(targetnumber):
- update_sheets()
- inboxrows = getrow('To', uname, 'email')
- if inboxrows == []:
- messagebox.showinfo("Email not found", "Hmmm... This email seems to no longer exist. Please refresh and try again.")
- else:
- email = int(targetnumber) - 1
- try:
- emailrow = inboxrows[int(email)]
- fromemail = python_emailsheet[emailrow]["From"]
- subject = python_emailsheet[emailrow]["Subject"]
- text = python_emailsheet[emailrow]["Text"]
- global emailattachment
- emailattachment = python_emailsheet[emailrow]["Attachment"]
- fromaccount = getrow("Address", fromemail, 'account')
- if fromaccount == None:
- fromname = "Unknown"
- else:
- fromname = python_accountsheet[fromaccount]["Name"]
- emailmessage = tk.Toplevel(root)
- emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
- tovar = tk.StringVar()
- fromvar = tk.StringVar()
- subjectvar = tk.StringVar()
- bodyvar = tk.StringVar()
- emailattachmentname = tk.StringVar()
- tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
- fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
- subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
- bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
- replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, fromemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- def downloadattachment():
- global emailattachment
- downloadattachmentname = emailattachment.partition('<Name Conts>')[0]
- downloadattachmentcontents = emailattachment.partition('<Name Conts>')[2]
- downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
- if not downloadname == '':
- downloadfile = open(downloadname, 'wb')
- downloadfile.write(downloadattachmentcontents.encode('latin1'))
- downloadfile.close()
- else:
- pass
- emailmessage.minsize(600, 400)
- emailmessage.resizable(False, True)
- emailmessage.configure(bg=global_bg_color)
- tovar.set('To: Me (' + uname + ')')
- fromvar.set('From: ' + fromname + ' (' + fromemail + ')')
- subjectvar.set('Subject: ' + subject)
- bodyvar.set(text)
- tolabel.place(x=10, y=10)
- fromlabel.place(x=10, y=30)
- subjectlabel.place(x=10, y=50)
- bodylabel.place(x=10, y=85)
- if not emailattachment == '':
- emailattachmentname.set(emailattachment.partition('<Name Conts>')[0])
- emailattachmentbutton = tk.Button(emailmessage, textvar=emailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- emailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
- emailmessage.title(subject + ' - TechMail')
- read = python_emailsheet[emailrow]["Read"]
- if read == 'F':
- emailsheet.update_cell(emailrow + 2, 6, 'T')
- except IndexError:
- messagebox.showinfo("Email not found", "Hmmm... This email seems to no longer exist. Please refresh and try again.")
- def outbox():
- todo = simpledialog.askstring("Outbox", "Type the number of the email in your outbox that you want to display:",
- parent=root_0)
- outboxrows = getrow(2, uname, 'email')
- if outboxrows[0] == 0:
- messagebox.showinfo("No emails", "You have not sent any emails.")
- else:
- email = int(todo) - 1
- try:
- emailrow = outboxrows[int(email)]
- toemail = emailsheet.cell(emailrow, 1).value
- subject = emailsheet.cell(emailrow, 3).value
- text = emailsheet.cell(emailrow, 4).value
- global sentemailattachment
- sentemailattachment = emailsheet.cell(emailrow, 5).value
- toaccount = getrow(1, toemail, 'account')
- if toaccount == 0:
- toname = "Unknown"
- else:
- toname = accountsheet.cell(toaccount, 2).value
- emailmessage = tk.Toplevel(root_0)
- emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
- tovar = tk.StringVar()
- fromvar = tk.StringVar()
- subjectvar = tk.StringVar()
- bodyvar = tk.StringVar()
- sentemailattachmentname = tk.StringVar()
- tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
- fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
- subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
- bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
- replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, toemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- def downloadattachment():
- global sentemailattachment
- downloadattachmentname = sentemailattachment.partition('<Name Conts>')[0]
- downloadattachmentcontents = sentemailattachment.partition('<Name Conts>')[2]
- downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
- if not downloadname == '':
- downloadfile = open(downloadname, 'wb')
- downloadfile.write(downloadattachmentcontents.encode('latin1'))
- downloadfile.close()
- else:
- pass
- emailmessage.minsize(600, 400)
- emailmessage.maxsize(600, 600)
- emailmessage.resizable(False, True)
- emailmessage.configure(bg=global_bg_color)
- tovar.set('To: ' + toname + ' (' + toemail + ')')
- fromvar.set('From: Me (' + uname + ')')
- subjectvar.set('Subject: ' + subject)
- bodyvar.set(text)
- tolabel.place(x=10, y=10)
- fromlabel.place(x=10, y=30)
- subjectlabel.place(x=10, y=50)
- bodylabel.place(x=10, y=85)
- if not sentemailattachment == '':
- sentemailattachmentname.set(sentemailattachment.partition('<Name Conts>')[0])
- sentemailattachmentbutton = tk.Button(emailmessage, textvar=sentemailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- sentemailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
- emailmessage.title(subject + ' - TechMail')
- except IndexError:
- messagebox.showinfo("Email not found", "That email doesn't exist. Please try again.")
- def outboxnew(targetnumber):
- update_sheets()
- outboxrows = getrow("From", uname, 'email')
- if outboxrows == []:
- messagebox.showinfo("Email not found", "Hmmm... This email seems to no longer exist. Please refresh and try again.")
- else:
- email = int(targetnumber) - 1
- try:
- emailrow = outboxrows[int(email)]
- toemail = python_emailsheet[emailrow]["To"]
- subject = python_emailsheet[emailrow]["Subject"]
- text = python_emailsheet[emailrow]["Text"]
- global sentemailattachment
- sentemailattachment = python_emailsheet[emailrow]["Attachment"]
- toaccount = getrow("Address", toemail, 'account')
- if toaccount == None:
- toname = "Unknown"
- else:
- toname = python_accountsheet[toaccount]["Name"]
- emailmessage = tk.Toplevel(root)
- emailmessage.iconphoto(False, tk.PhotoImage(file=photofile))
- tovar = tk.StringVar()
- fromvar = tk.StringVar()
- subjectvar = tk.StringVar()
- bodyvar = tk.StringVar()
- sentemailattachmentname = tk.StringVar()
- tolabel = tk.Label(emailmessage, textvar=tovar, justify='left', wraplength=550, bg=global_bg_color)
- fromlabel = tk.Label(emailmessage, textvar=fromvar, justify='left', wraplength=550, bg=global_bg_color)
- subjectlabel = tk.Label(emailmessage, textvar=subjectvar, justify='left', wraplength=550, bg=global_bg_color)
- bodylabel = tk.Label(emailmessage, textvar=bodyvar, justify='left', wraplength=550, bg=global_bg_color)
- replybutton = tk.Button(emailmessage, text='Reply', command=lambda: reply(subject, toemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- def downloadattachment():
- global sentemailattachment
- downloadattachmentname = sentemailattachment.partition('<Name Conts>')[0]
- downloadattachmentcontents = sentemailattachment.partition('<Name Conts>')[2]
- downloadname = filedialog.asksaveasfilename(parent=emailmessage, filetypes=[('All files', '*')], initialfile=downloadattachmentname, title='Save as')
- if not downloadname == '':
- downloadfile = open(downloadname, 'wb')
- downloadfile.write(downloadattachmentcontents.encode('latin1'))
- downloadfile.close()
- else:
- pass
- emailmessage.minsize(600, 400)
- emailmessage.resizable(False, True)
- emailmessage.configure(bg=global_bg_color)
- tovar.set('To: ' + toname + ' (' + toemail + ')')
- fromvar.set('From: Me (' + uname + ')')
- subjectvar.set('Subject: ' + subject)
- bodyvar.set(text)
- tolabel.place(x=10, y=10)
- fromlabel.place(x=10, y=30)
- subjectlabel.place(x=10, y=50)
- bodylabel.place(x=10, y=85)
- if not sentemailattachment == '':
- sentemailattachmentname.set(sentemailattachment.partition('<Name Conts>')[0])
- sentemailattachmentbutton = tk.Button(emailmessage, textvar=sentemailattachmentname, command=downloadattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- sentemailattachmentbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- replybutton.pack(side='left', anchor='sw', padx=5, pady=5)
- emailmessage.title(subject + ' - TechMail')
- except IndexError:
- messagebox.showinfo("Email not found", "That email doesn't exist. Please try again.")
- def compose():
- global composeform
- composeform = tk.Toplevel(root)
- composeform.iconphoto(False, tk.PhotoImage(file=photofile))
- composeform.minsize(600, 469)
- composeform.maxsize(600, 469)
- composeform.resizable(False, False)
- composeform.configure(bg=global_bg_color)
- global toinput
- global subjectinput
- global bodyinput
- global attachment
- attachment = ''
- global attachmentname
- global attachmentvar
- attachmentvar = tk.StringVar()
- attachmentvar.set("")
- def addattachment():
- global attachment
- global attachmentname
- global attachmentvar
- filepath = filedialog.askopenfilename(parent=composeform, filetypes=[('All Files', '*'), ('Text Files', '.txt'), ('Image Files', '.png .jpg'), ('Python Files', '.py .pyw')], title='Open File to Attach')
- file = open(filepath, 'rb')
- filetext = file.read().decode('latin1')
- if len(filetext) > 50000:
- messagebox.showinfo("Cannot load attachment", "We cannot load attachments over 50 KB. Please upload a different file.")
- else:
- attachmentname = os.path.basename(filepath)
- attachmentvar.set(attachmentname)
- attachment = attachmentname + "<Name Conts>" + filetext
- tolabel = tk.Label(composeform, text="To", justify="left", bg=global_bg_color)
- toinput = tk.Entry(composeform, width=30, bd=1, relief='solid')
- subjectinputtext = tk.StringVar()
- subjectlabel = tk.Label(composeform, text="Subject", justify="left", bg=global_bg_color)
- subjectinput = tk.Entry(composeform, width=30, bd=1, relief='solid', textvar=subjectinputtext)
- subjectinputtext.trace("w", lambda *args: character_limit(subjectinputtext))
- bodylabel = tk.Label(composeform, text="Message", justify="left", bg=global_bg_color)
- bodyframe = tk.Frame(composeform, bd=1, relief='solid')
- bodyinput = tk.Text(bodyframe, font='TkDefaultFont', bd=0)
- attachmentbutton = tk.Button(composeform, text="Attach", command=addattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- attachmentlabel = tk.Label(composeform, textvar=attachmentvar, justify="left", bg=global_bg_color)
- composeformsubmit = tk.Button(composeform, text="Send", command=sendemail, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- tolabel.place(x=5, y=5)
- toinput.place(x=5, y=25)
- subjectlabel.place(x=5, y=45)
- subjectinput.place(x=5, y=65)
- bodylabel.place(x=5, y=85)
- bodyframe.place(x=5, y=105, width=590, height=300)
- bodyinput.pack(expand=True, fill='both')
- attachmentbutton.place(x=5, y=410)
- attachmentlabel.place(x=50, y=410)
- composeformsubmit.place(x=5, y=440)
- def reply(subject, toemail):
- update_sheets()
- global replyform
- replyform = tk.Toplevel(root)
- replyform.iconphoto(False, tk.PhotoImage(file=photofile))
- replyform.minsize(600, 429)
- replyform.maxsize(600, 429)
- replyform.resizable(False, False)
- replyform.configure(bg=global_bg_color)
- toaccount = getrow("Address", toemail, 'account')
- if toaccount == None:
- toname = "Unknown"
- else:
- toname = python_accountsheet[toaccount]["Name"]
- if subject[:4] == 'RE: ':
- fullsubject = subject
- else:
- fullsubject = 'RE: ' + subject
- global replybodyinput
- global replyattachment
- replyattachment = ''
- global replyattachmentname
- global replyattachmentvar
- replyattachmentvar = tk.StringVar()
- replyattachmentvar.set("")
- def replyaddattachment():
- global replyattachment
- global replyattachmentname
- global replyattachmentvar
- filepath = filedialog.askopenfilename(parent=replyform,
- filetypes=[('All Files', '*'), ('Text Files', '.txt'), ('Image Files', '.png .jpg'),
- ('Python Files', '.py .pyw')], title='Open File to Attach')
- file = open(filepath, 'rb')
- filetext = file.read().decode('latin1')
- if len(filetext) > 50000:
- messagebox.showinfo("Cannot load attachment",
- "We cannot load attachments over 50 KB. Please upload a different file.")
- else:
- replyattachmentname = os.path.basename(filepath)
- replyattachmentvar.set(replyattachmentname)
- replyattachment = replyattachmentname + "<Name Conts>" + filetext
- tolabel = tk.Label(replyform, text="To: " + toname + " (" + toemail + ")", justify="left", bg=global_bg_color)
- subjectlabel = tk.Label(replyform, text="Subject: " + fullsubject, justify="left", bg=global_bg_color)
- bodylabel = tk.Label(replyform, text="Message", justify="left", bg=global_bg_color)
- bodyframe = tk.Frame(replyform, bd=1, relief='solid')
- replybodyinput = tk.Text(bodyframe, font='TkDefaultFont', bd=0)
- replyattachmentbutton = tk.Button(replyform, text="Attach", command=replyaddattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- replyattachmentlabel = tk.Label(replyform, textvar=replyattachmentvar, justify="left", bg=global_bg_color, font='Quicksand 10')
- replyformsubmit = tk.Button(replyform, text="Send", command=lambda: sendreply(fullsubject, toemail), bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- tolabel.place(x=5, y=5)
- subjectlabel.place(x=5, y=25)
- bodylabel.place(x=5, y=45)
- bodyframe.place(x=5, y=65, width=590, height=300)
- replybodyinput.pack(expand=True, fill='both')
- replyattachmentbutton.place(x=5, y=370)
- replyattachmentlabel.place(x=50, y=370)
- replyformsubmit.place(x=5, y=400)
- def feedback():
- global feedbackform
- feedbackform = tk.Toplevel(root)
- feedbackform.iconphoto(False, tk.PhotoImage(file=photofile))
- feedbackform.minsize(600, 389)
- feedbackform.maxsize(600, 389)
- feedbackform.resizable(False, False)
- feedbackform.configure(bg=global_bg_color)
- global feedbackbodyinput
- global feedbackattachment
- feedbackattachment = ''
- global feedbackattachmentname
- global feedbackattachmentvar
- feedbackattachmentvar = tk.StringVar()
- feedbackattachmentvar.set("")
- def faddattachment():
- global feedbackattachment
- global feedbackattachmentname
- global feedbackattachmentvar
- filepath = filedialog.askopenfilename(parent=composeform, filetypes=[('All Files', '*'), ('Text Files', '.txt'), ('Image Files', '.png .jpg'), ('Python Files', '.py .pyw')], title='Open File to Attach')
- file = open(filepath, 'rb')
- filetext = file.read().decode('latin1')
- if len(filetext) > 50000:
- messagebox.showinfo("Cannot load attachment", "We cannot load attachments over 50 KB. Please upload a different file.")
- else:
- feedbackattachmentname = os.path.basename(filepath)
- feedbackattachmentvar.set(feedbackattachmentname)
- feedbackattachment = feedbackattachmentname + "<Name Conts>" + filetext
- bodylabel = tk.Label(feedbackform, text="Tell us what's on your mind!", justify="left", bg=global_bg_color)
- bodyframe = tk.Frame(feedbackform, bd=1, relief='solid')
- feedbackbodyinput = tk.Text(bodyframe, font='TkDefaultFont', bd=0)
- attachmentbutton = tk.Button(feedbackform, text="Attach", command=faddattachment, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- attachmentlabel = tk.Label(feedbackform, textvar=feedbackattachmentvar, justify="left", bg=global_bg_color)
- feedbackformsubmit = tk.Button(feedbackform, text="Send", command=sendfeedback, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- bodylabel.place(x=5, y=5)
- bodyframe.place(x=5, y=25, width=590, height=300)
- feedbackbodyinput.pack(expand=True, fill='both')
- attachmentbutton.place(x=5, y=330)
- attachmentlabel.place(x=50, y=330)
- feedbackformsubmit.place(x=5, y=360)
- def sendemail():
- update_sheets()
- toemail = tk.StringVar()
- subject = tk.StringVar()
- text = tk.StringVar()
- toemail.set(toinput.get())
- subject.set(subjectinput.get())
- text.set(bodyinput.get("1.0", "end"))
- composeform.destroy()
- row = [toemail.get(), uname, subject.get(), text.get(), attachment, 'F']
- emailsheet.insert_row(row, 2)
- toaccount = getrow("Address", toemail.get(), 'account')
- if toaccount == None:
- messagebox.showinfo("Email sent", "Successfully sent email to " + toemail.get())
- else:
- messagebox.showinfo("Email sent", "Successfully sent email to " + python_accountsheet[toaccount]["Name"] + " (" + toemail.get() + ")")
- def sendfeedback():
- update_sheets()
- text = tk.StringVar()
- text.set(feedbackbodyinput.get("1.0", "end"))
- feedbackform.destroy()
- row = ['Techpad@techmail.com', uname, 'Feedback', text.get(), feedbackattachment, 'F']
- emailsheet.insert_row(row, 2)
- messagebox.showinfo('Feedback Sent', 'We\'ve recieved your feedback! We\'ll respond if we think it\'s important.')
- def sendreply(subject, toemail):
- update_sheets()
- text = tk.StringVar()
- text.set(replybodyinput.get("1.0", "end"))
- replyform.destroy()
- row = [toemail, uname, subject, text.get(), replyattachment, 'F']
- emailsheet.insert_row(row, 2)
- toaccount = getrow('Address', toemail, 'account')
- if toaccount == None:
- messagebox.showinfo("Reply sent", "Successfully sent reply to " + toemail)
- else:
- messagebox.showinfo("Reply sent", "Successfully sent reply to " + python_accountsheet[toaccount]["Name"] + " (" + toemail + ")")
- def checkemails(): # Function to check emails
- global inboxtext
- global outboxtext
- global Thread
- global time
- try:
- try:
- usernamelabel.destroy()
- except:
- pass
- try:
- usernameinput.destroy()
- except:
- pass
- try:
- passwordlabel.destroy()
- except:
- pass
- try:
- passwordinput.destroy()
- except:
- pass
- try:
- loginformsubmit.destroy()
- except:
- pass
- try:
- newusernamelabel.destroy()
- except:
- pass
- try:
- newusernameinput.destroy()
- except:
- pass
- try:
- namelabel.destroy()
- except:
- pass
- try:
- nameinput.destroy()
- except:
- pass
- try:
- newpasswordlabel.destroy()
- except:
- pass
- try:
- newpasswordinput.destroy()
- except:
- pass
- try:
- verifypasswordlabel.destroy()
- except:
- pass
- try:
- verifypasswordinput.destroy()
- except:
- pass
- try:
- signupformsubmit.destroy()
- except:
- pass
- try:
- loginsignupbutton.destroy()
- except:
- pass
- try:
- signuploginbutton.destroy()
- except:
- pass
- except:
- pass
- def whileloading():
- update_sheets()
- root_0.update()
- global maincanvas
- global parentframe
- parentframe = tk.Frame(root_0, bd=0, bg='white')
- maincanvas = tk.Canvas(parentframe, bg='white', highlightthickness=0)
- scrollbar = tk.Scrollbar(parentframe, orient="vertical", command=maincanvas.yview)
- mainframe = tk.Frame(maincanvas, bg='white')
- mainframe.bind(
- "<Configure>",
- lambda e: maincanvas.configure(
- scrollregion=maincanvas.bbox("all")
- )
- )
- maincanvas.create_window((0, 0), window=mainframe, anchor="nw", tags=["window1"], width=675)
- maincanvas.configure(yscrollcommand=scrollbar.set)
- def _on_mousewheel(event):
- maincanvas.yview_scroll(int(-1 * (event.delta / 120)), "units")
- maincanvas.bind_all("<MouseWheel>", _on_mousewheel)
- inboxrows = getrow("To", uname, 'email') # Get rows of emails that were sent to the user
- sentrows = getrow("From", uname, 'email') # Get rows of emails that were sent by the user
- emailnumber = 1 # Used later
- inboxtext = tk.StringVar()
- if inboxrows == []:
- aminem = "0"
- else:
- aminem = str(len(inboxrows))
- if sentrows == []:
- amseem = "0"
- else:
- amseem = str(len(sentrows))
- 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")
- inboxlabel = tk.Label(mainframe, textvar=inboxtext, justify="left", padx=50, bg=global_bg_color)
- inboxlabel.pack(side='top', anchor='nw')
- outboxtext = tk.StringVar()
- 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")
- if inboxrows == []: # If there are no emails to display
- inboxtext.set(inboxtext.get() + "There are no emails in your inbox.")
- else: # If there are emails to display
- for element in inboxrows: # For loop to display inbox
- readt = python_emailsheet[element]["Read"]
- if readt == 'F':
- read = False
- elif readt == 'T':
- read = True
- sentfrom = python_emailsheet[element]["From"]
- subject = python_emailsheet[element]["Subject"]
- text = python_emailsheet[element]["Text"]
- fromaccount = getrow("Address", sentfrom, "account")
- if fromaccount == None:
- fromname = "Unknown"
- else:
- fromname = python_accountsheet[fromaccount]["Name"]
- if text[-1] == '\n':
- text = text[:-1]
- if len(text) > 25:
- text = text[:25] + "..."
- if "\n" in text:
- text = text.partition("\n")[0] + "..."
- emailbuttontext = "\u2014 " + fromname + " (" + sentfrom + ")\n Subject: " + subject + "\n \"" + text + "\""
- 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)
- if read == False:
- emailbutton.config(font='TkDefaultFont 9 bold')
- else:
- pass
- emailbutton.pack(expand=True, fill='x')
- emailnumber += 1
- outboxlabel = tk.Label(mainframe, textvar=outboxtext, justify="left", padx=50, bg=global_bg_color)
- outboxlabel.pack(side="top", anchor="nw")
- if sentrows == []:
- outboxtext.set(outboxtext.get() + "You have not sent any emails.")
- else:
- emailnumber = 1
- for element in sentrows:
- sentto = python_emailsheet[element]["To"]
- subject = python_emailsheet[element]["Subject"]
- text = python_emailsheet[element]["Text"]
- toaccount = getrow("Address", sentto, "account")
- if toaccount == None:
- toname = "Unknown"
- else:
- toname = python_accountsheet[toaccount]["Name"]
- if text[-1] == '\n':
- text = text[:-1]
- if len(text) > 25:
- text = text[:25] + "..."
- if "\n" in text:
- text = text.partition("\n")[0] + "..."
- emailbuttontext = "\u2014 Me, " + toname + " (" + sentto + ")\n Subject: " + subject + "\n \"" + text + "\""
- 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)
- emailbutton.pack(expand=True, fill='x')
- emailnumber += 1
- readabilityspacer = tk.Label(mainframe, text='\n\n\n', bg='white')
- readabilityspacer.pack()
- #showinboxbutton = tk.Button(parentframe, text="Show inbox email", command=inbox, bg='white', bd=1, relief='solid',
- # activebackground='#ddeeff')
- #showoutboxbutton = tk.Button(parentframe, text="Show sent email", command=outbox, bg='white', bd=1, relief='solid',
- # activebackground='#ddeeff')
- composebutton = tk.Button(parentframe, text="Compose", command=compose, bg='white', bd=1, relief='solid',
- activebackground='#ddeeff', cursor='hand2')
- refreshbutton = tk.Button(parentframe, text="Refresh", command=refreshemails, bg='white', bd=1, relief='solid',
- activebackground='#ddeeff', cursor='hand2')
- logoutbutton = tk.Button(parentframe, text="Logout", command=logout, bg='white', bd=1, relief='solid',
- activebackground='#ddeeff', cursor='hand2')
- accountbutton = tk.Button(parentframe, text="Account", command=account, bg='white', bd=1, relief='solid',
- activebackground='#ddeeff', cursor='hand2')
- helpbutton = tk.Button(parentframe, text="Help", command=help, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- feedbackbutton = tk.Button(parentframe, text="Feedback", command=feedback, bg='white', bd=1, relief='solid', activebackground='#ddeeff', cursor='hand2')
- #showinboxbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- #showoutboxbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- composebutton.pack(side='left', anchor='sw', padx=5, pady=5)
- refreshbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- logoutbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- accountbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- helpbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- feedbackbutton.pack(side='left', anchor='sw', padx=5, pady=5)
- parentframe.pack(expand=True, fill="both")
- maincanvas.place(x=0, y=0, relwidth=1.0, relheight=1.0)
- scrollbar.pack(side="right", fill="y")
- global isloading
- isloading = 'false'
- loadingthread = Thread(target=whileloading, daemon=True)
- loadingthread.start()
- def loadingscreen():
- global isloading
- global time
- isloading = 'true'
- frames = [tk.PhotoImage(file=loadingimage, format='gif -index %i' % (i)) for i in
- range(20)]
- def update(ind, numreps, ttf):
- global time
- if isloading == 'true':
- frame = frames[ind]
- if ind < 19:
- ind += 1
- elif ind == 19:
- ind = 0
- numreps += 1
- if numreps == 500:
- 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.")
- loadinglabel.configure(image=frame)
- if ttf < 50:
- ttf += 1
- elif ttf == 50:
- tip = random.choice(tips)
- tiplabel.configure(text=tip)
- ttf = 0
- root_0.update()
- time.sleep(0.05)
- update(ind, numreps, ttf)
- else:
- loadinglabel.destroy()
- tiplabel.destroy()
- loadinglabel = tk.Label(root_0, bg=global_bg_color, anchor='center')
- loadinglabel.place(relwidth=1.0, relheight=1.0)
- tiplabel = tk.Label(root_0, bg=global_bg_color, anchor='n', text='Loading...', wraplength=300, pady=20, font='Quicksand 10')
- tiplabel.pack()
- root_0.after(0, update, 0, 0, 50)
- root_0.update()
- loadingscreenthread = Thread(target=loadingscreen, daemon=True)
- loadingscreenthread.start()
- def refreshemails():
- parentframe.destroy()
- #inboxlabel.destroy()
- #outboxlabel.destroy()
- #showinboxbutton.destroy()
- #showoutboxbutton.destroy()
- #composebutton.destroy()
- #refreshbutton.destroy()
- #logoutbutton.destroy()
- #accountbutton.destroy()
- #helpbutton.destroy()
- checkemails()
- def logout():
- uname = 'Guest'
- rname = 'Guest'
- try:
- mainframe.destroy()
- except:
- pass
- try:
- maincanvas.destroy()
- except:
- pass
- try:
- parentframe.destroy()
- except:
- pass
- try:
- signuploginbutton.destroy()
- except:
- pass
- startup()
- def yeet():
- yeetcode = """import tkinter as tk
- import random
- stuff = frame1
- eastereggtips = """ + str(eastereggtips) + """
- yeetl = tk.Label(stuff, text='Stuff', font='Quicksand 25', pady=20, bg=global_bg_color, fg='dodgerblue', padx=5)
- yeetl.pack(side='top', anchor='nw')
- def rickroll(e):
- os.system('start https://www.youtube.com/watch?v=DLzxrzFCyOs')
- meme = random.choice(eastereggtips)
- if meme == "Click here for an egg salad subcontrabass piccolo dish":
- memebutton = tk.Label(stuff, text=meme, padx=5, bg=global_bg_color, wraplength=590, justify='left')
- memebutton.bind('<Button-1>', rickroll)
- memebutton.pack(side='top', anchor='nw')
- else:
- memelabel = tk.Label(stuff, text=meme, padx=5, bg=global_bg_color, wraplength=590, justify='left')
- memelabel.pack(side='top', anchor='nw')"""
- yeetwindow = create_window(width=400, height=300, title='Stuff', img='T:/Programs/TechMail/Attributes/Icon.png', code=yeetcode)
- def startup(): # On startup, do this
- global logolabel
- global versionlabel
- try:
- logolabel.destroy()
- versionlabel.destroy()
- except:
- pass
- global titlelabel
- titlelabel = tk.Label(root_0, text='\nTechMail', image=largeicon, font='Quicksand 40', pady=15, bg=global_bg_color, fg='dodgerblue')
- titlelabel.pack(pady=50)
- global loginbutton
- loginbutton = tk.Button(root_0, bg='white', bd=0, relief='solid', activebackground='white', image=loginbuttonimage, cursor='hand2')
- def loginbuttonpressed(e):
- loginbutton.config(image=loginpressedimage)
- return "break"
- def loginbuttonreleased(e):
- loginbutton.config(image=loginbuttonimage)
- x, y = root_0.winfo_pointerxy()
- widget = root_0.winfo_containing(x, y)
- if widget == loginbutton:
- login()
- else:
- pass
- loginbutton.bind("<Button-1>", loginbuttonpressed)
- loginbutton.bind("<ButtonRelease-1>", loginbuttonreleased)
- loginbutton.pack()
- global spacer
- spacer = tk.Label(root_0, text='', bg=global_bg_color)
- spacer.pack()
- global signupbutton
- signupbutton = tk.Button(root_0, bg='white', bd=0, relief='solid', activebackground='white', image=signupbuttonimage, cursor='hand2', command=yeet)
- def signupbuttonpressed(e):
- signupbutton.config(image=signuppressedimage)
- return "break"
- def signupbuttonreleased(e):
- signupbutton.config(image=signupbuttonimage)
- x, y = root_0.winfo_pointerxy()
- widget = root_0.winfo_containing(x, y)
- if widget == signupbutton:
- signup()
- else:
- pass
- signupbutton.bind("<Button-1>", signupbuttonpressed)
- signupbutton.bind("<ButtonRelease-1>", signupbuttonreleased)
- signupbutton.pack()
- startup() # Run startup function
- startupthread = Thread(target=runprogram, daemon=True)
- startupthread.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement