Shcoder001

Password Generator

Jan 19th, 2023
960
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. import customtkinter
  2. import tkinter
  3. import random
  4.  
  5. customtkinter.set_appearance_mode("dark")  # Modes: system (default), light, dark
  6. customtkinter.set_default_color_theme("blue")
  7.  
  8. chars = 'qwertyuiopasdfghjklzxcvbnm'
  9. symbols = '+-#&%#$@^*$'
  10.  
  11. chars = list(chars + chars.upper() + symbols)
  12.  
  13.  
  14. def generate():
  15.     len_passwords = int(entry_len.get())
  16.     count_passwords = int(entry_count.get())
  17.     for i in range(count_passwords):
  18.         password = ''
  19.         for j in range(len_passwords):
  20.             password += random.choice(chars)
  21.         text_field.insert(tkinter.END, password+'\n')
  22.  
  23.  
  24. def clear():
  25.     text_field.delete(0.0, tkinter.END)
  26.  
  27.  
  28. window = customtkinter.CTk()
  29. window.title('Генератор')
  30. window.geometry('600x600')
  31.  
  32. customtkinter.CTkLabel(window, text='Кол-во паролей: ').place(x=170, y=30)
  33. entry_count = customtkinter.CTkEntry(window, width=50)
  34. entry_count.place(x=290, y=30)
  35.  
  36. customtkinter.CTkLabel(window, text='Длина паролей: ').place(x=170, y=60)
  37. entry_len = customtkinter.CTkEntry(window, width=50)
  38. entry_len.place(x=290, y=60)
  39.  
  40. btn_clear = customtkinter.CTkButton(window, text='Очистить', command=clear)
  41. btn_clear.place(x=350, y=100)
  42.  
  43. btn_generate = customtkinter.CTkButton(window, text='Генерировать', command=generate)
  44. btn_generate.place(x=150, y=100)
  45.  
  46. text_field = customtkinter.CTkTextbox(window, width=560, height=400)
  47. text_field.place(x=20, y=150)
  48.  
  49. window.mainloop()
  50.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment