Skip to content

Commit

Permalink
Some code cleaning and a quality of life improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
IceTheCoder committed Jan 14, 2023
1 parent 600c18e commit 7ca208e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Binary file modified PasswordGenerator/__pycache__/logic.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion PasswordGenerator/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def generatePassword(requested_length) -> str:
:raises ValueError: if the requested_length is not an integer.
'''

if int(requested_length) > 0:
if requested_length > 0:
return ''.join(secrets.choice(characters) for i in range(min(int(requested_length), 100))) # This is where the password itself is generated
else:
raise ValueError
9 changes: 4 additions & 5 deletions PasswordGenerator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def createPasswordLabels(event) -> None:

try:
for password_label in password_labels:
password = logic.generatePassword(input_box.get())
password = logic.generatePassword(int(input_box.get()))
showPassword(password_label, password, password_labels.index(password_label))

except ValueError:
input_box.delete(0, 'end')
showPassword(password_label_1, error, 0)

input_box = tk.Entry(window, width = 10, borderwidth = 2)
Expand All @@ -74,16 +75,14 @@ def showPassword(label, text, index) -> None:
label.configure(state = 'disabled') # Makes the text uneditable.


done_btn_image = tk.PhotoImage(file = 'doneButton.png')
DONE_BUTTON_IMAGE = tk.PhotoImage(file = 'doneButton.png')

DONE_BUTTON_BORDER_WIDTH = 0

done_btn = tk.Button(window, image = done_btn_image, borderwidth = DONE_BUTTON_BORDER_WIDTH, command = lambda: createPasswordLabels(None))
done_btn = tk.Button(window, image = DONE_BUTTON_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 7ca208e

Please sign in to comment.