Skip to content

Commit

Permalink
Merge pull request #62 from GamerSoft24/assist-mail-change
Browse files Browse the repository at this point in the history
assist app - made email thingy easier
  • Loading branch information
GamerSoft24 authored Nov 7, 2024
2 parents 2f7e58c + 924bde7 commit fc8d60c
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Programs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Programs

## [PySoft](https://github.com/GamerSoft24/Software/tree/Main/PySoft)

1 -> [Assistant App(assistant app.py):](https://github.com/GamerSoft24/Software/tree/Main/PySoft/Assistant%20App.py) The security management system of the GUI days!

### [Calculators:](https://github.com/GamerSoft24/Software/tree/Main/PySoft/Calculators)

1 -> [Advanced Calculator (advanced calculator.py):](https://github.com/GamerSoft24/Software/blob/Main/PySoft/Calculators/advanced%20calculator.py) A replica for a really basic trignometry calculator.
Expand Down
146 changes: 124 additions & 22 deletions PySoft/assistant app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tkinter as tk
from tkinter import messagebox, simpledialog
import datetime
from tkinter import messagebox, simpledialog, filedialog
from tkinter import *
import datetime
import requests
import webbrowser
import smtplib
Expand Down Expand Up @@ -33,7 +34,7 @@ def __init__(self, *args, **kwargs):

self.frames = {}

for F in (MainMenu, CurrentDateTime, OpenWebPage, SendEmail, RandomJoke, SystemCommand, GamesMenu, TicTacToe):
for F in (MainMenu, CurrentDateTime, OpenWebPage, SendEmail, RandomJoke, SystemCommand, GamesMenu, TicTacToe, TextEditor, ToolsMenu, PassManager):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
Expand All @@ -59,6 +60,8 @@ def __init__(self, parent, controller):
("Fetch a Random Joke.", lambda: controller.show_frame(RandomJoke)),
("Execute a System Command.", lambda: controller.show_frame(SystemCommand)),
("Games Menu.", lambda: controller.show_frame(GamesMenu)),
("Text Editor", lambda: controller.show_frame(TextEditor)),
("Tools Menu", lambda: controller.show_frame(ToolsMenu)),
("Exit.", self.quit)
]

Expand All @@ -74,15 +77,16 @@ def __init__(self, parent, controller):
label = tk.Label(self, text="Current Date and Time.", font=('Arial', 18, 'bold'))
label.pack(pady=10, padx=10)

now = datetime.datetime.now()
now = self.gettime()
datetime_str = now.strftime('%Y-%m-%d %H:%M:%S')

datetime_label = tk.Label(self, text=datetime_str, font=('Arial', 14))
datetime_label = tk.Label(self, text=self.gettime().strftime('%Y-%m-%d %H:%M:%S'), font=('Arial', 14))
datetime_label.pack(pady=10)

back_button = tk.Button(self, text="Back to Menu.", command=lambda: controller.show_frame(MainMenu))
back_button.pack(pady=10)

def gettime(self):
return datetime.datetime.now()
class OpenWebPage(tk.Frame):
def __init__(self, parent, controller):
super().__init__(parent)
Expand Down Expand Up @@ -134,25 +138,24 @@ def __init__(self, parent, controller):
back_button.pack(pady=10)

def send_email(self):
smpt = simpledialog.askstring("SMTP Server","Enter an SMTP server for your mail provider. Default is 'smtp.gmail.com'\nIf you do not spell it correctly, you will get an error!")
port = simpledialog.askinteger("SMTP Server Port","Enter a port for your SMTP server. Default for GMail is 587")
mail = simpledialog.askstring("Email address","Enter an email address that corresponds to your provider. This will affect how the password works.")
pwd = simpledialog.askstring("Password","Enter an app or regular password. Gmail requires app passwords due to security restrictions, which can be found at https://myaccount.google.com/apppasswords.\nIf with another email provider, check for more info.")
smpt = simpledialog.askstring("SMTP Server","Enter an SMTP server for your mail provider. Default is 'smtp.gmail.com'\nIf you do not spell it correctly, you will get an error!\nIf you are using an other email provider, please search online or check their websites.")
port = simpledialog.askinteger("SMTP Server Port","Enter a port for your SMTP server. Default port for Gmail is 587.\nIf you are using an other email provider, please search online or check their websites.")
mail = simpledialog.askstring("Email address",'Enter an email address that corresponds to your provider. This is crucial for this email functionality to work properly. e.g. "example@gmail.com", "example@yahoo.fr", "example@163.com" or "example@qq.com".')
assist-mail-change
pwd = simpledialog.askstring("Password",'Enter an app or regular passwords. Gmail requires app passwords due to security restrictions, which can be found at "https://myaccount.google.com/apppasswords".\nIf you are using an other email provider, please search online or check their websites.')
Main
to_email = self.to_entry.get()
subject = self.subject_entry.get()
message = self.message_text.get("1.0", tk.END)

from_email = mail
app_pwd_or_std_pwd = pwd # Replace with your Gmail App Password. Most attempts using regular password will not work due to security restrictions. If you want to use an other mail provider, check their security restrictions to see if you need an app password like Gmail or not.

msg = MIMEMultipart()
msg['From'] = from_email
msg['To'] = to_email
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))

try:
server = smtplib.SMTP(smpt, port) # You can change the SMTP server and port here if you want a different mail provider like Outlook or Yahoo. Search online for more information.
server = smtplib.SMTP(smpt, port)
server.starttls()
server.login(from_email, app_pwd_or_std_pwd)
server.sendmail(from_email, to_email, msg.as_string())
Expand Down Expand Up @@ -189,7 +192,7 @@ def fetch_joke(self):
joke = response.json()
self.joke_label.config(text=f"{joke['setup']}\n{joke['punchline']}.")
else:
messagebox.showerror("Joke.", "Failed to fetch joke from API.")
messagebox.showerror("Joke.", "Failed to fetch joke from API, check firewall and internet restrictions.")
except Exception as e:
messagebox.showerror("Joke.", f"Failed to fetch joke. Error: {str(e)}.")

Expand All @@ -207,7 +210,7 @@ def __init__(self, parent, controller):
execute_button = tk.Button(self, text="Execute.", command=self.execute_command)
execute_button.pack(pady=5)

self.output_text = tk.Text(self, width=80, height=10)
self.output_text = tk.Text(self, width=80, height=18)
self.output_text.pack(pady=10)

back_button = tk.Button(self, text="Back to Menu.", command=lambda: controller.show_frame(MainMenu))
Expand All @@ -226,7 +229,39 @@ def execute_command(self):
except Exception as e:
self.output_text.delete("1.0", tk.END)
self.output_text.insert(tk.END, f"Failed to execute command. Error: {str(e)}.")

class TextEditor(Frame):
def __init__(self,parent,controller):
super().__init__(parent)
self.controller = controller
l1 = Label(self,text="Text Editor - By Okmeque1",font=('Arial',18,'bold'))
l1.pack(pady=10,padx=10)
self.text = Text(self,width=80,height=20)
self.text.pack(pady=10)
l2 = Label(self,text="File Name")
l2.pack(pady=5)
self.filename = Entry(self,width=40)
self.filename.pack(pady=10)
load = Button(self,text="Load",command=lambda: self.load(),width=40)
load.pack(pady=5)
save = Button(self,text="Save",command=lambda: self.save(),width=40)
save.pack(pady=5)
menu = Button(self,text="Return to Main Menu",command=lambda: controller.show_frame(MainMenu),width=40)
menu.pack()
def load(self):
try:
with open(self.filename.get(),"r") as reading:
self.text.delete("1.0",END)
self.text.insert(END,reading.read())
except Exception as e:
x = messagebox.showerror("Assistant App - Load failed",f"Load failed. Error : {str(e)}")
def save(self):
try:
with open(self.filename.get(), "w") as writing:
writing.write(self.text.get("1.0",END))
x = messagebox.showinfo("Assistant App","Save complete.")
except Exception as e:
x = messagebox.showerror("Assistant App - Save failed",f"Save failed. Error : {str(e)}")

class GamesMenu(tk.Frame):
def __init__(self, parent, controller):
super().__init__(parent)
Expand Down Expand Up @@ -268,8 +303,8 @@ def __init__(self, parent, controller):
button.pack(side="left", padx=5, pady=5)
self.buttons.append(button)

reset_button = tk.Button(self, text="Reset.", command=self.reset_game)
reset_button.pack(pady=10)
#reset_button = tk.Button(self, text="Reset.", command=self.reset_game)
#reset_button.pack(pady=10)

back_button = tk.Button(self, text="Back to Games Menu.", command=lambda: controller.show_frame(GamesMenu))
back_button.pack(pady=10)
Expand Down Expand Up @@ -299,8 +334,75 @@ def reset_game(self):
for button in self.buttons:
button.config(text=" ")
self.current_player = "X"

if __name__ == "__main__":
class ToolsMenu(Frame):
def __init__(self,parent,controller):
super().__init__(parent)
self.controller = controller
label = tk.Label(self, text="Tools Menu - By Okmeque1", font=('Arial', 18, 'bold'))
label.pack(pady=10, padx=10)
pwd = Button(self, text="Password Manager", command=lambda: controller.show_frame(PassManager))
pwd.pack(pady=5)
smsr = Button(self, text="Remove Start Menu Search Results",command=lambda: self.start())#Windows Only, removes bing search results
smsr.pack(pady=5)
def start(self):
if os.name != 'nt':
x = messagebox.showwarning("Assistant App","The 'Windows Start Menu Internet Search Remover' is not compatible with your operating system.")
return
a = os.system("reg add HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Explorer\DisableSearchBoxSuggestions /d 1")
if a != 0:
x = messagebox.showerror("Assistant App","Please run this program with admin privileges.")
else:
x = messagebox.askyesno("Assistant App","The operation has completed successfully. For the changes to take effect, the Windows Explorer must be restarted and will take a few moments. Restart?",icon=messagebox.QUESTION)
if x:
os.system('taskkill /f /im explorer.exe')
os.system('explorer')
class PassManager(Frame):
def __init__(self,parent,controller):
super().__init__(parent)
self.controller = controller
label = tk.Label(self, text="Password Manager - By Okmeque1", font=('Arial', 18, 'bold'))
label.pack(pady=10, padx=10)
b1 = Button(self,text="Generate password",command=lambda: self.gen())
b1.pack(pady=5)
b2 = Button(self,text="Retrieve password",command=lambda: self.retrieve())
b2.pack(pady=5)
b3 = Button(self,text="List passwords",command=lambda: self.showall())
b3.pack(pady=5)
self.t1 = Text(self,width=80,height=18)
self.t1.pack(pady=10)
def gen(self):
charlen = simpledialog.askinteger("Assistant App","Enter password length")
setname = simpledialog.askstring("Assistant App","Enter password name")
charset = '¦¬`1!23£4$€5%6^7&8*9(0)-_=+qQwWeErRtTyYuUiIoOpPaAsSdDfFgGhHjJkKlL;:@~#\|zZxXcCvVbBnNmMm,<.>/?'
pwd = ""
for x in range(charlen):
pwd += random.choice(charset)
filename = simpledialog.askstring("Assistant App","Please enter a valid file name. The format must be 'A:\Directory\Subdirectory\file.extension'.")
try:
with open(filename,"a") as add:
add.write(f"\n{setname} -> {pwd}")
x = messagebox.showinfo("Assistant App","Generated and saved successfully")
except Exception as e:
x = messagebox.showerror("Assistant App - Save failed",f"Save failed. Error : {e}")
def retrieve(self):
filename = filedialog.askopenfilename(filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")])
if filename:
with open(filename,"r") as passopen:
set1 = simpledialog.askstring("Assisant App","Enter password name")
for line in passopen:
if line.split(" -> ")[0] == set1:
x = messagebox.showinfo("Assistant App","The password is " + str({line.split(" -> ")[1]}))
self.t1.delete("1.0",END)
self.t1.insert(END,"The password for the password name is ")
self.t1.insert(END,line.split(" -> ")[1])
def showall(self):
filename = filedialog.askopenfilename(filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")])
if filename:
with open(filename,"r") as listall:
self.t1.delete("1.0",END)
self.t1.insert(END,"The passwords for this file are :\n")
self.t1.insert(END,listall.read())
if __name__ == "__main__":#uarte
app = AssistantApp()
app.geometry("600x500")
app.geometry("800x600")
app.mainloop()

0 comments on commit fc8d60c

Please sign in to comment.