from tkinter import * import random root = Tk() e1 = Entry(width=50) def insert(): e1.delete(0, 'end') password = "" for i in range(0,10): password += chr(random.randrange(97, 97 + 26)) e1.insert(0, password) but = Button(text="Генерировать пароль", command=insert) e1.pack() but.pack() root.mainloop()