I am creating a simple password generator, it should make a new one every time I press the button. How would I do that? Every time I do it, it prints/shows the same password. I think I understand why it's not working the way I want it to but I don't know how to fix it. Thank you.
from tkinter import *
import random
def password_generator():
numbers = "1234567890"
upper_case_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lower_case_letters = "abcdefghijklmnopqrstuvwxyz"
special_chars = "!@#$%^&*()[];:"
password_length = random.randint(9, 15)
combo = numbers + upper_case_letters + lower_case_letters + special_chars
password = "".join(random.sample(combo, password_length))
return password
def printSomething():
label = Label(window, text = password)
label.pack()
password = password_generator()
window = Tk()
window.geometry("400x250")
window.title("Password Generator")
window.config(background = "black")
button = Button(window, text = "Generate")
button.pack()
button.config(command = printSomething)
button.config(font = ("", 50, "bold"))
window.mainloop()