Reputation: 47
The image i imported is not displaying on the button. Any ideas why?
eye_img = PhotoImage(file="Eye.gif")
eye_img = eye_img.subsample(19)
show_password = Button(canvas, width = 31, image=eye_img, height = 17, bg = "#E2E6EF", relief = "flat", command = Show)
canvas_show_password = canvas.create_window(660, 355, window = show_password)
Here is a screenshot of the button display (invisible as the image isn't there).
https://gyazo.com/910e4a5ac539a463feca1955cc1d1abb
Upvotes: 0
Views: 67
Reputation: 47
After some more research I discovered that this occurred because their was no reference added to the image. It was thus being removed from memory upon execution. Adding the following line of code solved the issue.
show_password.image = eye_img
To read up some more on this visit this website. http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htm
Upvotes: 2