37,719
社区成员
发帖
与我相关
我的任务
分享
image= The image object. This should be a PhotoImage or BitmapImage, or a compatible object (such as the PIL PhotoImage). The application must keep a reference to the image object.
from tkinter import *
root = Tk()
cv = Canvas(root, bg = 'white', width = 500, height = 650)
rt = cv.create_rectangle(10,10,110,110,outline='red',stipple='gray12',fill='green')
imgs= [PhotoImage(file='/tmp/'+str(i)+'.gif') for i in range(3)]
for img in imgs:
cv.create_image((20*i,200*i),image=img)
cv.pack()
root.mainloop()
另外, 也许你知道:
'D:\\python\\bmp\\'
可以用"raw string":
r'D:\python\bmp\'
即使是在windows下,也可以用'D:/python/bmp/'