from tkinter import *
# ---------------------------- PASSWORD GENERATOR ------------------------------- #
# ---------------------------- SAVE PASSWORD ------------------------------- #
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Password Manager")
window.config(padx=20, pady=20)
#TODO: Create Image and put on top of Canvas
canvas = Canvas(width=200,height=200,highlightthickness=0)
mypass_img = PhotoImage(file="logo.png")
#TODO: image widht and height setup as half of Canvas width and height
canvas.create_image(100,100,image=mypass_img)
canvas.grid(column=1, row=1)
window.mainloop()
from tkinter import *
# ---------------------------- PASSWORD GENERATOR ------------------------------- #
def generate_password():
pass
# ---------------------------- SAVE PASSWORD ------------------------------- #
def save_password():
pass
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Password Manager")
window.config(padx=50, pady=50)
#TODO: Create Image and put on top of Canvas
canvas = Canvas(width=200,height=200,highlightthickness=0)
mypass_img = PhotoImage(file="logo.png")
canvas.create_image(100,100,image=mypass_img)
canvas.grid(column=1,row=0)
#create label
website_lbl = Label(text="Website", highlightthickness=0)
website_lbl.grid(column=0,row=2)
email_lbl = Label(text="Email/Username", highlightthickness=0)
email_lbl.grid(column=0,row=3)
password_lbl = Label(text="Password", highlightthickness=0)
password_lbl.grid(column=0,row=4)
#create entry
website_txt = Entry(width=42)
website_txt.grid(column=1,row=2,columnspan = 2)
email_txt = Entry(width=42)
email_txt.grid(column=1,row=3,columnspan = 2)
password_txt = Entry(width=25)
password_txt.grid(column=1,row=4)
#create button
generate_password_button = Button(text="Generate Password")
generate_password_button.grid(column=2, row=4)
add_button = Button(width=42, text="Add", highlightthickness=0, command=save_password)
add_button.grid( column=1, row=5, columnspan = 2)
window.mainloop()
from tkinter import *
# ---------------------------- PASSWORD GENERATOR ------------------------------- #
def generate_password():
pass
# ---------------------------- SAVE PASSWORD ------------------------------- #
#TODO:save password
'''
1.Create a function called Save()
2. Write to the data inside the entries to a Data.txt file when the Add button is clicked
3. Each website, email and password combination should be on a new line inside the file
4. All fields need to be cleared after add button is pressed
'''
def save_password():
#to fetch entry's value by call get() function of Entry
password_string = f"{website_txt.get()}|{email_txt.get()}|{password_txt.get()} \\n"
print(password_string)
with open("my_password.txt","a") as filewrite:
filewrite.writelines(password_string)
#clear All fields
website_txt.delete(0,END)
password_txt.delete(0,END)
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Password Manager")
window.config(padx=50, pady=50)
#TODO: Create Image and put on top of Canvas
canvas = Canvas(width=200,height=200,highlightthickness=0)
mypass_img = PhotoImage(file="logo.png")
canvas.create_image(100,100,image=mypass_img)
canvas.grid(column=1,row=0)
website_lbl = Label(text="Website", highlightthickness=0)
website_lbl.grid(column=0,row=2)
email_lbl = Label(text="Email/Username", highlightthickness=0)
email_lbl.grid(column=0,row=3)
password_lbl = Label(text="Password", highlightthickness=0)
password_lbl.grid(column=0,row=4)
website_txt = Entry(width=42)
website_txt.grid(column=1,row=2,columnspan = 2)
website_txt.focus()
email_txt = Entry(width=42)
email_txt.grid(column=1,row=3,columnspan = 2)
email_txt.insert(0, "[email protected]")
password_txt = Entry(width=25)
password_txt.grid(column=1,row=4)
generate_password_button = Button(text="Generate Password")
generate_password_button.grid(column=2, row=4)
add_button = Button(width=42, text="Add", highlightthickness=0, command=save_password)
add_button.grid( column=1, row=5, columnspan = 2)
window.mainloop()
tkinter.messagebox - Tkinter message prompts - Python 3.10.4 documentation
from tkinter import *
from tkinter import messagebox
# ---------------------------- PASSWORD GENERATOR ------------------------------- #
def generate_password():
pass
# ---------------------------- SAVE PASSWORD ------------------------------- #
#TODO:save password
'''
1.Create a function called Save()
2. Write to the data inside the entries to a Data.txt file when the Add button is clicked
3. Each website, email and password combination should be on a new line inside the file
4. All fields need to be cleared after add button is pressed
'''
def save_password():
#to fetch entry's value by call get() function of Entry
password_string = f"{website_txt.get()}|{email_txt.get()}|{password_txt.get()} \\n"
print(password_string)
if website_txt.get() == "":
messagebox.showinfo(title="Password manager", message="website field can't be empty")
website_txt.focus()
elif password_txt.get() == "":
messagebox.showinfo(title="Password manager", message="password field can't be empty")
password_txt.focus()
else:
#messagebox.showinfo(title="Title", message="Hello")
isok = messagebox.askyesno(title="website", message="Password information to be save or not?")
print(isok)
if isok:
with open("my_password.txt","a") as filewrite:
filewrite.writelines(password_string)
#clear All fields
website_txt.delete(0,END)
password_txt.delete(0,END)
messagebox.showinfo(title="Password manager", message="Password has been saved!")
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Password Manager")
window.config(padx=50, pady=50)
#TODO: Create Image and put on top of Canvas
canvas = Canvas(width=200,height=200,highlightthickness=0)
mypass_img = PhotoImage(file="logo.png")
canvas.create_image(100,100,image=mypass_img)
canvas.grid(column=1,row=0)
website_lbl = Label(text="Website", highlightthickness=0)
website_lbl.grid(column=0,row=2)
email_lbl = Label(text="Email/Username", highlightthickness=0)
email_lbl.grid(column=0,row=3)
password_lbl = Label(text="Password", highlightthickness=0)
password_lbl.grid(column=0,row=4)
website_txt = Entry(width=42)
website_txt.grid(column=1,row=2,columnspan = 2)
website_txt.focus()
email_txt = Entry(width=42)
email_txt.grid(column=1,row=3,columnspan = 2)
email_txt.insert(0, "[email protected]")
password_txt = Entry(width=25)
password_txt.grid(column=1,row=4)
generate_password_button = Button(text="Generate Password")
generate_password_button.grid(column=2, row=4)
add_button = Button(width=42, text="Add", highlightthickness=0, command=save_password)
add_button.grid( column=1, row=5, columnspan = 2)
window.mainloop()