所以,我到目前为止得到的代码会使黄色圆圈出现在蓝色圆圈中,但问题是我希望黄色圆圈在蓝色圆圈出现后一秒钟上传到画布。
这是我到目前为止所得到的:
import tkinter
import time
root = tkinter.Tk()
canvas = tkinter.Canvas(width=500, height=500)
canvas.pack()
for i in range(100):
canvas.create_line(20 * i, 0, 20 * i, 800)
canvas.create_line(0, 20 * i, 800, 20 * i)
canvas.create_oval(20, 20, 480, 480, fill="blue")
canvas.create_oval(100, 100, 400, 400, fill="yellow")
root.mainloop()
答案 0 :(得分:2)
使用.after()
import tkinter
import time
root = tkinter.Tk()
canvas = tkinter.Canvas(width=500, height=500)
canvas.pack()
for i in range(100):
canvas.create_line(20 * i, 0, 20 * i, 800)
canvas.create_line(0, 20 * i, 800, 20 * i)
canvas.create_oval(20, 20, 480, 480, fill="blue")
make_oval= lambda : canvas.create_oval(100, 100, 400, 400, fill="yellow")
root.after(1000,make_oval)
root.mainloop()