Time.sleep in Kivy(Kivy 中的 Time.sleep)
问题描述
我正在 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.clock
推荐答案
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 中的 Time.sleep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Kivy 中的 Time.sleep


基础教程推荐
- 修改列表中的数据帧不起作用 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 包装空间模型 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 求两个直方图的卷积 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01