问题描述
我最近刚开始学习python。我曾尝试使用 Thonny。我在诸如 Why does Tkinter image not show up if created in a function? 和 Tkinter.PhotoImage doesn't not support png image,但还没有发现类似的问题......我曾尝试阅读文档,但很挣扎。
当我将 PhotoImage 保存为变量然后使用 canvas.create_image 时,图像显示正确:
tomato_img = PhotoImage(file="/Users/kwanh/PycharmProjects/day-28/tomato.png")
canvas.create_image(110,112,image=tomato_img)
但是,当我没有将 PhotoImage 保存为变量时,图像不再显示:
canvas.create_image(110,image=PhotoImage(file="/Users/kwanh/PycharmProjects/day-28/tomato.png"))
我想我可以将它保存为一个变量,但想知道是不是因为我做错了什么?我使用类型函数来检查变量或不变量是否属于
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)