为什么加载gif文件的这种奇异的代码在python 3中起作用而在python 2中不起作用?

时间:2019-02-18 03:20:19

标签: python python-2.7 kivy kivy-language

我尝试使用python 2编译以下代码,但出现错误。

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_string("""
<ExampleApp>:
    orientation: "vertical"
    Button:
        text: ""
        on_press: gif.anim_delay = 0.10
        on_press: gif._coreimage.anim_reset(True)

        Image:
            id: gif
            source: 'img.gif'
            center: self.parent.center
            size: 500, 500
            allow_stretch: True
            anim_delay: -1
            anim_loop: 1
""")

class ExampleApp(App, BoxLayout):
    def build(self):
        return self

if __name__ == "__main__":
   ExampleApp().run() 

这是我在Windows上遇到的错误:

C:\Python27\kivy-rubik-master\teste>C:\Python27\python.exe main.py

[INFO   ] [Logger      ] Record log in C:\Users\Vivaldo\.kivy\logs\kivy_19-02-18
_112.txt

[INFO   ] [Kivy        ] v1.10.1

[INFO   ] [Python      ] v2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [
MSC v.1500 32 bit (Intel)]

[INFO   ] [Factory     ] 194 symbols loaded

[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif
 (img_ffpyplayer ignored)

[INFO   ] [Window      ] Provider: sdl2

[INFO   ] [GL          ] Using the "OpenGL" graphics system

[INFO   ] [GL          ] GLEW initialization succeeded

[INFO   ] [GL          ] Backend used <glew>

[INFO   ] [GL          ] OpenGL version <3.1.0 - Build 9.17.10.4229>

[INFO   ] [GL          ] OpenGL vendor <Intel>

[INFO   ] [GL          ] OpenGL renderer <Intel(R) HD Graphics 3000>

[INFO   ] [GL          ] OpenGL parsed version: 3, 1

[INFO   ] [GL          ] Shading version <1.40 - Intel Build 9.17.10.4229>

[INFO   ] [GL          ] Texture max size <8192>

[INFO   ] [GL          ] Texture max units <16>

[INFO   ] [Window      ] auto add sdl2 input provider

[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked

[INFO   ] [Text        ] Provider: sdl2

[ERROR  ] [Image       ] Error loading texture img.gif

[INFO   ] [Base        ] Start application main loop

[INFO   ] [Base        ] Leaving application in progress...

点击按钮后,我收到此错误。

AttributeError: 'NoneType' object has no attribute 'anim_reset'

0 个答案:

没有答案