在基维(Kivy)上的时间睡眠 [英] Time.sleep in Kivy
问题描述
我正在寻找Kivy中的time.sleep
之类的东西,因为kivy不支持time.sleep
,并且当我使用time.sleep
运行程序时它会挂起.
我搜索并找到了一个函数:
I am looking for some thing like time.sleep
in Kivy, because kivy does not support time.sleep
and it hangs when i run a program using time.sleep
.
I searched and found a function called:
Clock.schedule_interval(self.callback, interval)
,但可能不像time.sleep
. Clock.schedule
每x秒调用一次函数,但我想延迟一下.
but its not probably like time.sleep
. Clock.schedule
calls a function every x seconds, but I want to make a delay.
推荐答案
kivy不支持time.sleep
kivy does not support time.sleep
Kivy支持time.sleep很好,它只是不执行您想要的工作-根据函数名称,它会休眠,这意味着kivy会冻结",因为它没有接受输入,因此无法更新图形等
Kivy supports time.sleep just fine, it just doesn't do what you want it to do - as per the function name, it sleeps, which means kivy 'freezes' as it isn't taking input, updating the graphics etc.
无论如何,听起来像您想要Clock.schedule_once(function, time)
.这将在time
秒内调用该函数(带有默认参数dt
).
Anyway, it sounds like you want Clock.schedule_once(function, time)
. That will call the function (with a default argument dt
) in time
seconds.
这篇关于在基维(Kivy)上的时间睡眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!