Skip to content

Commit

Permalink
Cleaned code and added a quality of life improvement
Browse files Browse the repository at this point in the history
Enter now does the same thing as the done button in the second tab
  • Loading branch information
IceTheCoder committed Jan 28, 2023
1 parent 575b234 commit 3533aec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
File renamed without changes
2 changes: 1 addition & 1 deletion password_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def main() -> None:
window.iconphoto(False, tk.PhotoImage(file = 'logo.png'))
window.title(app_name)

done_btn_image = ImageTk.PhotoImage(Image.open('done_button.png'))
done_btn_image = ImageTk.PhotoImage(Image.open('done_btn.png'))

class GeneratePasswordFrame:
'''
Expand Down
13 changes: 10 additions & 3 deletions password_generator/password_strength.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
modified_common_passwords = []

for line in common_passwords_read:
modified_common_passwords.append(line.strip())
modified_common_passwords.append(line.strip()) # Places each of the 100,000 most commonly used passwords into a list

def show_password_strength_frame(frame, done_btn_image):
'''
Expand All @@ -31,8 +31,10 @@ def show_password_strength_frame(frame, done_btn_image):
global input_box
input_box = tk.Entry(frame, width = 16, borderwidth = 2)
input_box.place(relx = 0.5, rely = 0.125, anchor = 'n')
input_box.bind('<Return>', check_password_strength)

done_btn = tk.Button(frame, image = done_btn_image, text = 'DONE', borderwidth = 0, command = check_password_strength)

done_btn = tk.Button(frame, image = done_btn_image, text = 'DONE', borderwidth = 0, command = lambda: check_password_strength(None))
done_btn.place(relx = 0.5, rely = 0.2, anchor = 'n')

global first_label
Expand All @@ -49,11 +51,16 @@ def show_password_strength_frame(frame, done_btn_image):



def check_password_strength():
def check_password_strength(event):
'''
Called upon pressing the done button,
this functions hosts all functions neccesary to check:
if a password is common, a password's length, a password's complexity, if a password contains repeated patterns.
Parameters
----------
event:
Necessary for initiating the function when pressing the ENTER key
'''
first_label.place_forget()
second_label.place_forget()
Expand Down

0 comments on commit 3533aec

Please sign in to comment.