尝试在Kivy玩GIF时的白色背景

时间:2018-05-26 16:48:17

标签: python python-3.x kivy gif kivy-language

import kivy
from kivy.clock import Clock
from functools import partial
import main as m
kivy.require("1.10.0")
from kivy.lang.builder import Builder
from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.anchorlayout import AnchorLayout
from kivy.core.window import Window
from kivy.uix.popup import Popup
from kivy.core.window import Window
Show_Func = Window.show
Window.size = (300, 100)
Window.borderless = True
Window.left = 1620
Window.top = 140
x = Builder.load_string("""
<GIF>:
    Image:
        id: img_gif
        source: '1.gif'
        anim_loop: 0
""")
class SampleApp(App):
    def build(self):
        return x
Clock.schedule_once(partial(m.Running_in_background, Show_Func),0.1)
if __name__ == '__main__':
    SampleApp().run()

当窗口显示为全白色,然后在10秒后开始无响应。我在谷歌找不到答案。谢谢你的帮助)

1 个答案:

答案 0 :(得分:0)

由于.gif文件需要很长时间才能加载,所以你应该首先将.gif的每一帧提取到一个文件夹中并使其成为.zip文件,你可以通过使用gimp并添加扩展来实现这一点,你可以下载从这里http://registry.gimp.org/node/28268扩展。然后加载.zip文件 像这样

Image:
   source: 'my.zip'