Skip to content

Commit

Permalink
Added GUI : Generate Password
Browse files Browse the repository at this point in the history
  • Loading branch information
ironjunk committed Apr 19, 2023
1 parent 6c5126d commit e3ce1ec
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 42 deletions.
Binary file added favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 50 additions & 11 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def btn_copy(text_field_1 = None):

# ---------- Functions : GUI Renders

# func: to remove existing UI
def gui_remove(root = None):

for widget in root.grid_slaves():
if int(widget.grid_info()["row"]) >= 1:
widget.grid_forget()
# ----------
# func: to draw the UI for first time setup
def gui_first_setup(root = None):

Expand Down Expand Up @@ -72,22 +79,54 @@ def gui_first_setup(root = None):
command = lambda: btn_first_setup(text_field_1 = text_field_1, text_field_2 = text_field_2, lbl_bottom = lbl_bottom))
btn_bottom.grid(row = 4, column = 0, columnspan = 2)
# ----------
# func: to draw the UI for first time setup
def gui_main_menu(root = None):
# func: to draw the UI for generate password tab
def gui_generate_password(root = None):

gui_remove(root = root)

text_field_1 = Entry(root, show = "*")
text_field_1.grid(row = 2, column = 0, columnspan = 2)
text_field_1.grid(row = 1, column = 1, columnspan = 2, pady = 20)

btn_generate = Button(root, text = "Generate",
command = lambda: btn_generate_password(text_field_1 = text_field_1))
btn_generate.grid(row = 1, column = 0, pady = 20)

btn_cpy = Button(root, text = "Copy",
command = lambda: btn_copy(text_field_1 = text_field_1))
btn_cpy.grid(row = 2, column = 3)
btn_cpy.grid(row = 1, column = 3, pady = 20)
# ----------
# func: to draw the UI for store password tab
def gui_store_password(root = None):

gui_remove(root = root)
# ----------
# ----------
# func: to draw the UI for first time setup
def gui_main_menu(root = None):

# text_field_1 = Entry(root, show = "*")
# text_field_1.grid(row = 1, column = 0, columnspan = 2)

# btn_cpy = Button(root, text = "Copy",
# command = lambda: btn_copy(text_field_1 = text_field_1))
# btn_cpy.grid(row = 1, column = 2)

btn_menu_generate = Button(root, text = "Generate\nPassword", padx = 20, pady = 20,
command = lambda: gui_generate_password(root = root))
btn_menu_generate.grid(row = 0, column = 0, pady = 20)

btn_menu_store = Button(root, text = "Store\nPassword", padx = 20, pady = 20,
command = lambda: gui_store_password(root = root))
btn_menu_store.grid(row = 0, column = 1, pady = 20)

btn_menu_update = Button(root, text = "Update\nPassword", padx = 20, pady = 20)
btn_menu_update.grid(row = 0, column = 2, pady = 20)

btn_top_1 = Button(root, text = "Generate\nPassword", padx = 20, pady = 20,
command = lambda: btn_generate_password(text_field_1 = text_field_1))
btn_top_1.grid(row = 0, column = 0)
btn_menu_retrieve = Button(root, text = "Retrieve\nPassword", padx = 20, pady = 20)
btn_menu_retrieve.grid(row = 0, column = 3, pady = 20)

btn_top_2 = Button(root, text = "Store\nPassword", padx = 20, pady = 20)
btn_top_2.grid(row = 0, column = 1)
# ---------- Main

btn_top_3 = Button(root, text = "Retrieve\nPassword", padx = 20, pady = 20)
btn_top_3.grid(row = 0, column = 2)
if __name__ == "__main__":

print("Error\t: Not a runnable program. \nNote\t: Run main.py instead.")
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# ---------- Required Modules

from tkinter import Tk
from tkinter import Tk, PhotoImage

from manager import check_status
from gui import gui_first_setup, gui_main_menu
Expand All @@ -17,6 +17,9 @@
root.title("Local Password Manager")
root.geometry('500x300')

favicon = PhotoImage(file = "favicon.png")
root.iconphoto(False, favicon)

if not check_status():
gui_first_setup(root = root)
else:
Expand All @@ -30,6 +33,7 @@
root.grid_columnconfigure(0, weight = 1)
root.grid_columnconfigure(1, weight = 1)
root.grid_columnconfigure(2, weight = 1)
root.grid_columnconfigure(3, weight = 1)

root.mainloop()

Expand Down
43 changes: 13 additions & 30 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,54 +106,37 @@ def check_master_pass(pass_master):
# ---------- Scope: Update {Begin} ---------- #
# ---------- Scope: Update {End} ---------- #

# ---------- Scope: Generate {Begin} ---------- #
# ---------- Generate Password

# func: to generate password
def generate(w = 4, W = 4, d = 3, s = 5):
# func: to jumble generated password
def jumble(gen):

jumbled = sample(gen, len(gen))

return "".join(jumbled)

spcl_char = "#_.@"

gen = ""

for i in range(w):
for _ in range(w):
gen = gen + chr(randint(97,122))

for i in range(W):
for _ in range(W):
gen = gen + chr(randint(65,90))

for i in range(d):
for _ in range(d):
gen = gen + chr(randint(48,57))

for i in range(s):
for _ in range(s):
gen = gen + spcl_char[randint(0,2)]

return jumble(gen)

# func: to extract parameter values
def separate(value):

return [int(x) for x in value]

# func: to jumble generated password
def jumble(gen):

jumbled = sample(gen, len(gen))

return "".join(jumbled)

# ---------- Scope: Generate {End} ---------- #

# ---------- Scope: Main {Begin} ---------- #
# ---------- Main

if __name__ == "__main__":

print("Error : Not a runnable program. \nNote : Run lpm_main.py")


# value = input("Enter Value: ")
# w, W, d, s = separate(value)

# pswd = generate(w, W, d, s)
# print(pswd)

# ---------- Scope: Main {End} ---------- #
print("Error\t: Not a runnable program. \nNote\t: Run main.py instead.")

0 comments on commit e3ce1ec

Please sign in to comment.