Kivy Gif动画运行太频繁了

2024-04-23 17:40:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用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`

Tags: the代码image程序sourcesizestringbuilder
1条回答
网友
1楼 · 发布于 2024-04-23 17:40:28

anim_loop属性应该可以在kivy1.9.0中使用,如果您使用的是旧版本,则考虑升级。在

还有另一种方法。可以使用以下代码停止动画:

myimage._coreimage.anim_reset(False)

要在动画播放后停止动画,请观察texture属性。它将在加载每个帧后更改。如果GIF有n帧,那么在调用on_texture方法(n+1)之后停止动画。在

^{pr2}$

相关问题 更多 >