import random
import tkinter as tk
from tkinter import Tk
root = tk.Tk()
root.geometry('300x250')
l3 = tk.Label(root, text='Пароли')
l3.pack()
lb1 = tk.Listbox(root, width=40)
lb1.pack()
chars = '+-/*!&$#?=@<>abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
def generator():
count = 3
length = 12
lb1.delete(0, 'end')
if count and length:
for n in range(count):
password = ''
for i in (length,):
password += random .choice(chars)
lb1.insert(0,password)
print(password)
def copy_to_clipboard(event):
print(event.widget.get('active'))
root.clipboard_clear()
root.clipboard_append(event.widget.get('active'))
root.update()
b1 = tk.Button(root, text='Создать', command=generator)
b1.pack()
lb1.bind('<Button-1>', copy_to_clipboard)
root.mainloop()