diff --git a/gui.py b/gui.py index a599b0c..88ee0b6 100644 --- a/gui.py +++ b/gui.py @@ -20,12 +20,12 @@ def btn_first_setup(text_field_1 = None, text_field_2 = None, lbl_bottom = None) success = mg.store_master_pass(pass_master) if success: - lbl_bottom.configure(text = f"{datetime.now()} :\nThe Master Password has been set successfully!\nNote: Kindly restart the app.", + lbl_bottom.configure(text = "The Master Password has been set successfully!\nNote: Kindly restart the app.", fg = 'green') else: - lbl_bottom.configure(text = f"{datetime.now()} :\nThe Master Password setup failed!\nKindly report to the developer.", fg = 'red') + lbl_bottom.configure(text = "The Master Password setup failed!\nKindly report to the developer.", fg = 'red') else: - lbl_bottom.configure(text = f"{datetime.now()} :\nThe passwords in both the fields do not match.\nPlease try again.", fg = 'red') + lbl_bottom.configure(text = "The passwords in both the fields do not match.\nPlease try again.", fg = 'red') # ---------- # func: to generate password def btn_generate_password(text_field_1 = None): @@ -35,11 +35,17 @@ def btn_generate_password(text_field_1 = None): text_field_1.insert(0, password) # insert into field # ---------- # func: to copy text from the text field -def btn_copy(text_field_1 = None): +def btn_copy_text(text_field_1 = None, lbl_bottom = None): text = text_field_1.get() copy(text = text) + lbl_bottom.configure(text = "Password copied to clipboard!", fg = 'green') +# ---------- +# func: to copy text from the text field +def btn_store_password(text_field_1 = None, text_field_2 = None, text_field_3 = None, lbl_bottom = None): + pass + # ---------- Functions : GUI Renders # func: to remove existing UI @@ -53,64 +59,90 @@ def gui_remove(root = None): def gui_first_setup(root = None): lbl_top = Label(root, text = "It seems like this is your first time using the program. Kindly follow the instructions to get the program set up.", - font = "Calibri 12", wraplength = 500, justify = "center", pady = 20) - lbl_top.grid(row = 0, column = 0, columnspan = 2) + font = "Calibri 12", wraplength = 500, justify = "center") + lbl_top.grid(row = 0, column = 0, columnspan = 2, pady = 20) lbl_mid = Label(root, text = "Set a Master Password to finish first time set up.", font = "Calibri 12 bold", wraplength = 500, justify = "center") lbl_mid.grid(row = 1, column = 0, columnspan = 2) - lbl_field_1 = Label(root, text = "Enter Master Password:", font = "Calibri 12", justify = "left", pady = 20) - lbl_field_1.grid(row = 2, column = 0) + lbl_field_1 = Label(root, text = "Enter Master Password:", font = "Calibri 12", justify = "left") + lbl_field_1.grid(row = 2, column = 0, pady = 10) - lbl_field_2 = Label(root, text = "Confirm Master Password:", font = "Calibri 12", justify = "left", pady = 20) - lbl_field_2.grid(row = 2, column = 1) + lbl_field_2 = Label(root, text = "Confirm Master Password:", font = "Calibri 12", justify = "left") + lbl_field_2.grid(row = 2, column = 1, pady = 10) text_field_1 = Entry(root, show = "*") - text_field_1.grid(row = 3, column = 0) + text_field_1.grid(row = 3, column = 0, pady = 10) text_field_2 = Entry(root, show = "*") - text_field_2.grid(row = 3, column = 1) + text_field_2.grid(row = 3, column = 1, pady = 10) lbl_bottom = Label(root, font = "Calibri 12 bold", wraplength = 500, justify = "center", pady = 20) - lbl_bottom.grid(row = 5, column = 0, columnspan = 2) + lbl_bottom.grid(row = 5, column = 0, columnspan = 2, pady = 20) btn_bottom = Button(root, text = "Set Master Password", 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) + btn_bottom.grid(row = 4, column = 0, columnspan = 2, pady = 10) # ---------- # 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 = Entry(root, show = "*", width = 30) 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) + lbl_bottom = Label(root, font = "Calibri 12 bold", wraplength = 500, justify = "center", pady = 20) + lbl_bottom.grid(row = 4, column = 0, columnspan = 4) + btn_cpy = Button(root, text = "Copy", - command = lambda: btn_copy(text_field_1 = text_field_1)) - btn_cpy.grid(row = 1, column = 3, pady = 20) + command = lambda: btn_copy_text(text_field_1 = text_field_1, lbl_bottom = lbl_bottom)) + 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) + + lbl_1 = Label(root, text = "ID : ", font = "Calibri 12", wraplength = 300, justify = "center") + lbl_1.grid(row = 1, column = 0, pady = 10) + + text_field_1 = Entry(root, width = 30) + text_field_1.grid(row = 1, column = 1, columnspan = 2, pady = 10) + + text_field_2 = Entry(root, show = "*", width = 30) + text_field_2.grid(row = 2, column = 1, columnspan = 2, pady = 10) + + btn_generate = Button(root, text = "Generate", + command = lambda: btn_generate_password(text_field_1 = text_field_2)) + btn_generate.grid(row = 2, column = 0, pady = 10) + + btn_cpy = Button(root, text = "Copy", + command = lambda: btn_copy_text(text_field_1 = text_field_2, lbl_bottom = lbl_bottom)) + btn_cpy.grid(row = 2, column = 3, pady = 10) + + lbl_2 = Label(root, text = "Master\nPassword : ", font = "Calibri 12", wraplength = 300, justify = "center") + lbl_2.grid(row = 3, column = 0, pady = 10) + + text_field_3 = Entry(root, show = "*", width = 30) + text_field_3.grid(row = 3, column = 1, columnspan = 2, pady = 10) + + lbl_bottom = Label(root, font = "Calibri 12 bold", wraplength = 500, justify = "center", pady = 20) + lbl_bottom.grid(row = 4, column = 0, columnspan = 4) + + btn_store = Button(root, text = "Store", + command = lambda: btn_store_password(text_field_1 = text_field_1, text_field_2 = text_field_2, text_field_3 = text_field_3, lbl_bottom = lbl_bottom)) + btn_store.grid(row = 3, column = 3, pady = 10) # ---------- # ---------- # 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) diff --git a/main.py b/main.py index de7c8ab..c6461d2 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ root = Tk() root.title("Local Password Manager") - root.geometry('500x300') + root.geometry('500x400') favicon = PhotoImage(file = "favicon.png") root.iconphoto(False, favicon)