【发布时间】:2017-12-09 20:01:20
【问题描述】:
在 Tkinter 画布中,我想显示 pic1.gif 并在 3 秒后将图片更改为 pic2.gif。当我运行下面的程序时,它会立即显示 pic2.gif。
from tkinter import *
from time import sleep
canvas_width = 300
canvas_height =300
master = Tk()
canvas = Canvas(master,
width=canvas_width,
height=canvas_height)
canvas.pack()
img = PhotoImage(file="pic1.gif")
canvas.create_image(20,20, anchor=NW, image=img)
sleep(3)
canvas.delete("all")
img = PhotoImage(file="pic2.gif")
canvas.create_image(20,20, anchor=NW, image=img)
mainloop()
非常感谢!
【问题讨论】:
标签: image python-3.x tkinter