我想用gif动画制作一个kivy程序,运行一次然后停止。 我将anim_循环设置为1,但它会不断重复运行。 代码如下:
Root = Builder.load_string('''
Image:
source: 'streifen1.gif'
size_hint_y: 1
anim_loop: 1
''')
class TTT(App):
def build(self):
Window.clearcolor = (0, 0.5, 1, 1)# sets the backgroundcolor
return Root #returnst the kv string and therefore the root widget`
anim_loop
属性应该可以在kivy1.9.0中使用,如果您使用的是旧版本,则考虑升级。在还有另一种方法。可以使用以下代码停止动画:
要在动画播放后停止动画,请观察
^{pr2}$texture
属性。它将在加载每个帧后更改。如果GIF有n帧,那么在调用on_texture
方法(n+1)之后停止动画。在相关问题 更多 >
编程相关推荐