-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
72 lines (54 loc) · 2.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from tkinter import *
from tkinter import messagebox
import random
import pyperclip
# ------------- PASSWORD GENERATOR -------------#
# ---------------- SAVE PASSWORD ------------------#
def save():
website = website_entry.get()
email = email_entry.get()
password = password_entry.get()
if len(website) == 0 or len(password) == 0:
messagebox.showinfo(title="oops", message="fill the all blank space")
else:
is_ok = messagebox.askokcancel(title=f"{website}",
message=f"these are the details"f" entred,\n Email:{email}\n"f"password {password}. is it ok?")
if is_ok:
with open("data.txt", "a") as data_file:
data_file.write(f"{website} | {email} | {password}\n")
website_entry.delete(0, END)
password_entry.delete(0, END)
# ---------------------- UI SETUP --------------#
window = Tk()
window.title("Password Manager")
window.config(padx=30, pady=30)
canvas = Canvas(width=200, height=200)
lock_image = PhotoImage(file="lock_image.png")
canvas.create_image(100, 60, image=lock_image)
canvas.grid(column=1, row=0)
# labels
website_label = Label(text="website")
website_label.grid(row=1, column=0)
website_label.config(padx=10, pady=10)
email_label = Label(text="email")
email_label.grid(row=2, column=0)
email_label.config(padx=10, pady=10)
password_label = Label(text="password")
password_label.grid(row=3, column=0)
password_label.config(padx=10, pady=10)
# entry
website_entry = Entry(width=35)
website_entry.grid(row=1, column=1)
website_entry.focus()
email_entry = Entry(width=29)
email_entry.grid(row=2, column=1)
email_entry.insert(0, "[email protected]") # this helps to display the text on entry bar
# given as argumet( index , "text")
password_entry = Entry(width=36)
password_entry.grid(row=3, column=1, )
# Buttons
generate_pass = Button(text="Generate password")
generate_pass.grid(column=2, row=3)
add_button = Button(text="Add", command=save)
add_button.grid(row=4, column=1)
window.mainloop()