在kivy运行一个GIF动画只有一次 [英] Run an gif animation only once on kivy

查看:466
本文介绍了在kivy运行一个GIF动画只有一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使一个 kivy应用它运行一个 gif动画

GIF动画应该是停止它的应用程序启动运行一次之后,但在 gif动画运行一遍又一遍,我不知道如何阻止它。

下面是code(这是很重要的一部分):

 级(BoxLayout的):
    通过
费尔德类(控件):
    WEG = StringProperty('test.gif')
    高清on_touch_down(个体经营,触摸):
        如果self.ids.my_image.collide_point(* touch.pos):
            通过根= Builder.load_string('''
水平:
    ID:水平
<水平计算值:
    方向:垂直
    BoxLayout的:
        ID:BOX1
        方向:水平
        费尔德:
            排名:100,310
            ID:A1
<费尔德计算值:
    图片:
        POS:root.pos
        ID:my_image
        来源:root.weg''')


解决方案

您应该设置的 anim_loop 属性:

  anim_loop添加在1.9.0    环路数玩,然后停止动画。 0表示保留动画。    anim_loop是NumericProperty默认为0。

I wanted to make an kivy app which runs an gif animation.

The gif animation is supposed to be stopped after it runs once on the application start, but the gif animation is running over and over again and I don't know how to stop it.

Here is the code(the part which is important):

class level(BoxLayout):
    pass


class Feld(Widget):
    weg = StringProperty('test.gif')
    def on_touch_down(self, touch):
        if self.ids.my_image.collide_point(*touch.pos):
            pass

Root = Builder.load_string('''
level:
    id: level
<level>:
    orientation: 'vertical'
    BoxLayout:
        id: box1
        orientation: 'horizontal'
        Feld:
            pos: 100, 310
            id: a1
<Feld>:
    Image:
        pos: root.pos
        id: my_image
        source: root.weg

''')

解决方案

You should set anim_loop property:

anim_loop                                                Added in 1.9.0

    Number of loops to play then stop animating. 0 means keep animating.

    anim_loop is a NumericProperty defaults to 0.

这篇关于在kivy运行一个GIF动画只有一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆