Tkinter - Image won't show up on button despite keeping global reference

别等时光非礼了梦想. 提交于 2019-12-01 22:44:57

I typically give PhotoImages a name and use the name in image parameters:

photo=tkinter.PhotoImage(name='close', file="close.gif")
close_button.config(image='close')

I'm not sure if this is the only way, but this works here.

The correct way to create the photoimage is by passing the path to the file parameter. Otherwise, your path gets assigned to the internal image name and thus no file will be associated with the image.

photo=tkinter.PhotoImage(file="close.gif")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!