Jul-10-2020, 05:40 PM
I am new to python. Can't seem to get the button to run the script to generate random passwords. Using py 3.8 and windows 10
from tkinter import * window=Tk() lbl=Label(window, text="You can generate 5 random passwords by pressing Run", fg='red', font=("Helvetica", 10)) lbl.place(x=60, y=50) btn=Button(window, text="Run", fg='blue', command = 'run') btn.place(x=80, y=100) window.title('Password Generator') window.geometry("500x500+10+10") def run(): import random import string def randomString(stringLength): letters = string.ascii_letters return ''.join(random.choice(letters) for i in range(stringLength)) print("Random String with the combination of lowercase and uppercase letters") print("First Random String is ", randomString(10)) print("second Random String is ", randomString(10)) print("thired Random String is ", randomString(10)) print("forth Random String is ", randomString(10)) print("fifth Random String is ", randomString(10)) window.mainloop()