Skip to content

Commit

Permalink
Press the Enter key to generate a password
Browse files Browse the repository at this point in the history
  • Loading branch information
IceTheCoder committed Jan 14, 2023
1 parent d0bd7bc commit 234f662
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Binary file modified PasswordGenerator/__pycache__/logic.cpython-310.pyc
Binary file not shown.
15 changes: 8 additions & 7 deletions PasswordGenerator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ def main():
question = tk.Label(window, text = 'Number of characters (up to 100):', font = DESCRIPTION_FONT)
question.grid(row = 3)

input_box = tk.Entry(window, width = 10, borderwidth = 2)
input_box.grid(row = 4)

tip = tk.Label(window, text = 'CTRL + C to copy \nCTRL + V to paste', font = DESCRIPTION_FONT)
tip.grid(row = 2)


def createPasswordLabels() -> None:
def createPasswordLabels(event) -> None:
'''
Called upon done button click,
this function creates the password/error label(s),
Expand Down Expand Up @@ -58,6 +54,9 @@ def createPasswordLabels() -> None:
except ValueError:
showPassword(password_label_1, error, 0)

input_box = tk.Entry(window, width = 10, borderwidth = 2)
input_box.bind("<Return>", createPasswordLabels)
input_box.grid(row = 4)

def showPassword(label, text, index) -> None:
'''
Expand All @@ -77,10 +76,12 @@ def showPassword(label, text, index) -> None:

DONE_BUTTON_BORDER_WIDTH = 0

done_btn = tk.Button(window, image = done_btn_image, borderwidth = DONE_BUTTON_BORDER_WIDTH, command = createPasswordLabels)
done_btn = tk.Button(window, image = done_btn_image, borderwidth = DONE_BUTTON_BORDER_WIDTH, command = lambda: createPasswordLabels(None))
done_btn.grid(row = 5, column = 0, pady = 10)

window.mainloop()

if __name__ == "__main__":
exit(main())


0 comments on commit 234f662

Please sign in to comment.