Reputation: 23
I've got a GUI running and ImageTK is already being used 3 times, but every time I add a new line using it that line gives a NameError :
NameError: name 'ImageTK' is not defined
An example of it running correctly (in a function showing a dice roll) :
img = Image.open("{}.png".format(rand_num))
die_img = ImageTk.PhotoImage(img)
die.config(image=die_img)
die.update()
Versus
img = Image.open("pb.png")
grave_img = ImageTK.PhotoImage(img)
pb1.config(image=grave_img)
pb1.update()
So it exists, then it doesn't exist. Help
Upvotes: 2
Views: 321
Reputation: 6857
Typo. You mistakenly capitalized the K in Tk. ImageTk
is not the same thing as ImageTK
. Tk
is correct, TK
is incorrect.
Upvotes: 2