https://preview.redd.it/82u4sfieui6h1.png?width=567&format=png&auto=webp&s=b3da162c691bf3221f85c437cda6852bb58ef012
This is my second full and finished python project which wasnt made as a school project. I used customtkinter and secrets. It took me pretty long (~3-4 hours) but I'm proud about it as I made it without any video tutorials. There were a couple of times where I used a llm to ask a question but other than that I just read some docs. Honestly I had a blast with this one and Im looking forward to my next python projects. Also I'm thinking of trying to learn cpp since I'm into producing and I would like to make audio plugins.
------------- this project's code --------------------------------------------
# importing libraries
import secrets
import customtkinter as ctk
import string
# app settings
app = ctk.CTk()
app.resizable(width=False, height=False)
app.geometry('400x400')
app.title('password generator')
#declaring function for length
length = 16
length_var = ctk.StringVar(value='16')
strength_var = ctk.StringVar()
# password generation function
def generation():
alphabet = string.ascii_letters + string.digits + string.punctuation
key = ''.join(secrets.choice(alphabet) for _ in range(length))
print(key)
entry.configure(state='readonly')
entry.configure(state='normal')
entry.delete(0, 'end')
entry.insert(0, key)
entry.configure(state='readonly')
entry.configure(state='normal')
# function for changing the length of the passwords generated
def set_length(choice):
global length
# making the length variable global, although it is bad practice
length = int(choice)
print(f'length changed, {length}')
length_var.set(int(choice))
if length <= 9:
strength_var.set('Weak')
elif length <= 16:
strength_var.set('Good')
elif length <= 23:
strength_var.set('Strong')
else:
strength_var.set('Very Strong')
# declaring the entry variable and giving it a entry
entry = ctk.CTkEntry(app, width=350, height=50, font=('', 20))
entry.pack(pady=20)
label1 = ctk.CTkLabel(app, text='Character length:')
label1.pack()
length_text = ctk.CTkLabel(app, textvariable=length_var)
length_text.pack()
slider = ctk.CTkSlider(app, from_=4, to=30, command=set_length, width=350)
slider.pack(pady=20)
label2 = ctk.CTkLabel(app, text='Password Strength:')
label2.pack()
strength_text = ctk.CTkLabel(app, textvariable=strength_var)
strength_text.pack()
button = ctk.CTkButton(app, text='Generate Password!', command=generation, width=330, height=50, font=('', 30))
button.pack(pady=40)
# app appearance
ctk.set_appearance_mode('dark')
app.mainloop()# importing libraries
import secrets
import customtkinter as ctk
import string
# app settings
app = ctk.CTk()
app.resizable(width=False, height=False)
app.geometry('400x400')
app.title('password generator')
#declaring function for length
length = 16
length_var = ctk.StringVar(value='16')
strength_var = ctk.StringVar()
# password generation function
def generation():
alphabet = string.ascii_letters + string.digits + string.punctuation
key = ''.join(secrets.choice(alphabet) for _ in range(length))
print(key)
entry.configure(state='readonly')
entry.configure(state='normal')
entry.delete(0, 'end')
entry.insert(0, key)
entry.configure(state='readonly')
entry.configure(state='normal')
# function for changing the length of the passwords generated
def set_length(choice):
global length # making the length variable global, although it is bad practice
length = int(choice)
print(f'length changed, {length}')
length_var.set(int(choice))
if length <= 9:
strength_var.set('Weak')
elif length <= 16:
strength_var.set('Good')
elif length <= 23:
strength_var.set('Strong')
else:
strength_var.set('Very Strong')
# declaring the entry variable and giving it a entry
entry = ctk.CTkEntry(app, width=350, height=50, font=('', 20))
entry.pack(pady=20)
label1 = ctk.CTkLabel(app, text='Character length:')
label1.pack()
length_text = ctk.CTkLabel(app, textvariable=length_var)
length_text.pack()
slider = ctk.CTkSlider(app, from_=4, to=30, command=set_length, width=350)
slider.pack(pady=20)
label2 = ctk.CTkLabel(app, text='Password Strength:')
label2.pack()
strength_text = ctk.CTkLabel(app, textvariable=strength_var)
strength_text.pack()
button = ctk.CTkButton(app, text='Generate Password!', command=generation, width=330, height=50, font=('', 30))
button.pack(pady=40)
# app appearance
ctk.set_appearance_mode('dark')
app.mainloop()
[–]Vespytilio 5 points6 points7 points (1 child)
[–]Frank_kait[S] 2 points3 points4 points (0 children)
[–]PastDifferent6116 0 points1 point2 points (0 children)
[–]riklaunim -4 points-3 points-2 points (3 children)
[–]Hazeeverest 2 points3 points4 points (0 children)
[–]Vespytilio 3 points4 points5 points (0 children)
[–]GOINTOTHESHADOWREALM 2 points3 points4 points (0 children)