tk is not defined when attempting to use a button in tkinter

Viewed 30

I have tried to create a button on python using tkinter, however I keep getting this error:

button1 = tk.Button(text='Length Of Password', command=generateRandomPassword)
NameError: name 'tk' is not defined. Did you mean: 'Tk'?

I have posted the code below, any help would be appreciated.

from tkinter import *

top=tk.Tk()

button1 = tk.Button(text='Length Of Password', command=generateRandomPassword)
button1.pack( side = LEFT)

top.mainloop()
0 Answers
Related