Skip to content

Commit e1fca5c

Browse files
authored
Merge pull request #52 from IceTheDev2/bug-password-strength-freeze
I DID IT BY BINDING EACH ELEMENT TO UPDATE THE WARNINGS WHEN CLICKED
2 parents cd471c0 + aa288c7 commit e1fca5c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

code/password_strength/password_strength_gui.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,38 @@ def __init__(self, master: customtkinter.CTkFrame, **kwargs) -> None:
3030
self.paste = tk.Menu(self, tearoff=False)
3131
self.paste.add_command(label='Paste', command=logic.paste_text)
3232

33-
instruction_label = customtkinter.CTkLabel(master=self, text='Type your password to check its strength',
34-
font=title_font)
35-
instruction_label.grid(column=0, row=0)
33+
self.instruction_label = customtkinter.CTkLabel(master=self, text='Type your password to check its strength',
34+
font=title_font)
35+
self.instruction_label.grid(column=0, row=0)
3636

37-
first_label = customtkinter.CTkLabel(master=self, font=warning_font, text=input_password_msg)
37+
self.first_label = customtkinter.CTkLabel(master=self, font=warning_font, text=input_password_msg)
3838

39-
second_label = customtkinter.CTkLabel(master=self, font=warning_font, text='')
39+
self.second_label = customtkinter.CTkLabel(master=self, font=warning_font, text='')
4040

41-
third_label = customtkinter.CTkLabel(master=self, font=warning_font, text='')
41+
self.third_label = customtkinter.CTkLabel(master=self, font=warning_font, text='')
4242

43-
fourth_label = customtkinter.CTkLabel(master=self, font=warning_font, text='')
43+
self.fourth_label = customtkinter.CTkLabel(master=self, font=warning_font, text='')
4444

45-
self.labels = [first_label, second_label, third_label, fourth_label]
45+
self.labels = [self.first_label, self.second_label, self.third_label, self.fourth_label]
4646

4747
for label in self.labels:
4848
label.grid(column=0, row=2 + self.labels.index(label), sticky='n')
4949

5050
self.input_box = customtkinter.CTkEntry(self, width=250, corner_radius=8)
5151
self.input_box.grid(column=0, row=1)
52+
53+
all_ui = [self.paste, self.instruction_label, self.input_box] + self.labels
54+
5255
# https://stackoverflow.com/questions/66035176/entry-widget-in-tkinter-with-key-bind
5356
self.input_box.bind('<KeyRelease>', lambda a: display_warnings(self.input_box, self.labels))
5457
self.input_box.bind('<Button-3>', lambda event: display_paste_button(event, self.paste))
5558
self.input_box.bind('<KeyPress>', fix.on_key_press)
5659
# https://stackoverflow.com/questions/75846986/certain-characters-like-%c8%9b-and-%c8%99-become-question-marks-as-i-type-them-in-a-tkin/76015278#76015278
5760

61+
for ui in all_ui:
62+
ui.bind('<Button-1>', lambda a: display_warnings(self.input_box, self.labels))
63+
ui.bind('<Button-3>', lambda a: display_warnings(self.input_box, self.labels))
64+
5865

5966
def display_paste_button(event: tkinter.Event, paste_menu: tkinter.Menu) -> None:
6067
"""

0 commit comments

Comments
 (0)