【发布时间】:2019-04-24 10:15:30
【问题描述】:
我想移动一个动画按钮。例如它从 x=0 和 y=0 开始,经过 0.1 秒 x=1 和 y=1 ... x=50 和 y=50。
我试过了:
import tkinter
import time
b=tkinter.Button(text="Example")
for i in range(50):
i+=1
b.place(x=i, y=i)
time.sleep(0.1)
执行完所有place命令后打开的窗口。
【问题讨论】:
-
因为 tkinter 是基于事件的,当在其中使用
sleep()时,您最终会冻结主循环。after()方法与事件管理器一起使用,因此不会发生这种情况。
标签: python button tkinter jquery-animate motion