【发布时间】:2020-02-28 08:28:58
【问题描述】:
from tkinter import *
window=Tk()
can=Canvas(window,width=500,height=500,bg="sky blue")
can.pack()
filename=PhotoImage(file="//home//maklab-embedded//Desktop//download.png")
image=can.create_image(0,0,anchor=SW,image=filename)
window.mainloop()
这段代码没有给出任何错误输出,但它没有在画布上显示任何图像。我该如何解决??
【问题讨论】:
-
改用
anchor=NW。您的代码将图像放在顶部上方,因此无法看到。 -
你为什么在路径中使用两个斜杠?
标签: python-3.x image tkinter tk tkinter-canvas