【发布时间】:2016-02-07 19:08:55
【问题描述】:
我需要更新一组标签,一次1个,但我还需要在功能完成之前查看更改的效果。期望的结果是一种加载条。
就目前而言,我的代码在函数结束时一次性应用所有更改。
(简化代码以方便阅读)
main.py
def TextAnimation(self):
#self.ids.??? are labels
self.ids.x1y1.text = "-"
self.ids.x2y1.text = "-"
self.ids.x3y1.text = "-"
self.ids.x1y1.texture_update()
self.ids.x2y1.texture_update()
self.ids.x3y1.texture_update()
time.sleep(0.2)
self.ids.x4y1.text = "-"
self.ids.x5y1.text = "-"
self.ids.x6y1.text = "-"
self.ids.x4y1.texture_update()
self.ids.x5y1.texture_update()
self.ids.x6y1.texture_update()
time.sleep(0.2)
我的印象是labelName.texture_update() 立即调用下一帧,而不是等待函数结束,但似乎不像文档中描述的那样工作;
Warning
The texture update is scheduled for the next frame. If you need the texture immediately after changing a property, you have to call the texture_update() method before accessing texture:
l = Label(text='Hello world')
# l.texture is good
l.font_size = '50sp'
# l.texture is not updated yet
l.texture_update()
# l.texture is good now.
【问题讨论】: