buildozer apk不加载GIF(在zip文件中作为jpg)

时间:2017-02-06 19:23:14

标签: android python-2.7 zip kivy buildozer

这是我的第一个kivy应用程序。它根据日期显示不同的图像。我的应用程序在Windows上完美运行,但在buildozer apk中,gifs(如zip文件中的jpg)被白色方块替换。与kivy发射器相同的问题。 在source.include_exts中添加了zip格式,并在buildozer.spec中添加了pil要求,但似乎没有任何效果。拉链位于正确的路径上(实际上它们显示在PC上)。 我的应用代码:

# coding=utf-8
from kivy.app import App
from random import random, randint,choice
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Rectangle
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
import datetime
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.image import Image

class MyButton(ButtonBehavior, Image):
    def __init__(self, **kwargs):
        super(MyButton, self).__init__(**kwargs)
        self.source = 'butto.png'
        self.size_hint = (0.3, 0.3)
    def on_press(self):
        self.source = 'pressed.png'
    def on_release(self,*args):
        self.source = 'butto.png'

class exitt(ButtonBehavior, Image):
    def __init__(self, **kwargs):
        super(exitt, self).__init__(**kwargs)
        self.source = 'exit.png'
    def on_press(self):
        self.source = 'bluext.png'
    def on_release(self,*args):
        self.source = 'exit.png'

class killbtn(ButtonBehavior, Image):
    def __init__(self, **kwargs):
        super(killbtn, self).__init__(**kwargs)
        self.source = 'killbtn.zip'
    def on_release(self,*args):
        self.source = 'killbtn.zip'



class ScreenOne(Screen):

    def __init__ (self,**kwargs):
        super (ScreenOne, self).__init__(**kwargs)
        my_box1 = FloatLayout()
        bubine = ['a','b']
        frasi=['a','b']
        bubilist= choice(bubine)
        buongglist=choice(frasi)
        my_label1 = Label(text="[color=ff3333]%s, %s![/color]" %(buongglist,bubilist),size_hint_y= .9, text_size=(330, None),halign= 'center', height=self.size[1],line_wrap=True, font_size='24dp', markup= True,pos_hint= {'center_x':.5, 'center_y':.77})
        my_button1=MyButton()
        my_button1.size_hint=(.6, .35)
        my_button1.pos_hint= {'center_x':.5, 'center_y':.3}
        my_button1.bind(on_release=self.changer)
        my_box1.add_widget(my_label1)
        my_box1.add_widget(my_button1)
        self.add_widget(my_box1)
        with self.canvas.before:
            Color(.5, .5, .9, 1)
            self.rect = Rectangle(pos=self.pos, size=self.size)
        self.bind(size=self.update_rect)
    def update_rect(self, instance, value):
        self.rect.pos = self.pos
        self.rect.size = self.size
    def my_callback(self,dt):
        App.get_running_app().stop()
    def changer(self,*args):
        legg=open('gg.txt', 'r')
        ultimogg=legg.readline()
        legg.close()
        oggi=datetime.datetime.now().strftime('%d')
        if ultimogg==oggi:
            kill= killbtn()
            kill.bind(on_press=self.uccidi)
            popup = Popup(title='Kill.',content=kill,size_hint=(.75,.75))
            popup.bind(on_dismiss=self.my_callback)
            popup.open()
        else:
            self.manager.current = 'screen3'
    def uccidi(self,*args):
        zipcaso=randint(1001,1013)
        load_zipped_png_files = Image(source = 'GIFS/%s.zip'% zipcaso,anim_loop=1,anim_delay = 0.1,keep_ratio = False,keep_data = True,size_hint=(1,1))
        popup = Popup(title='Cosi impara.',content=load_zipped_png_files,size_hint=(.75,.75))
        popup.bind(on_dismiss=self.my_callback)
        popup.open()


class ScreenThree(Screen):
    def __init__(self,**kwargs):
        super (ScreenThree,self).__init__(**kwargs)
        my_box1 = FloatLayout()
        oggi=datetime.datetime.now().strftime('%d')
        if oggi=='23'or oggi=='14'or oggi=='26' or oggi=='01':
            mese=datetime.datetime.now().strftime('%m')
            if  oggi=='23' and mese=='07':
                numoggi = 'luglio'
            elif  oggi=='14'and mese=='02':
                popup = Popup(title='Buon',content=Label(text='Hello world'),size_hint=(.75,.75))
                popup.open()
                numoggi = 'febbraio'
            elif oggi=='26' and mese=='08':
                numoggi = 'agosto'
            elif oggi=='01' and mese=='01':
                numoggi = 'gennaio'
        else:
            legg=open('numimg.txt', 'r')
            ultimogg=legg.readline()
            legg.close()
            if ultimogg=='1004':
                numoggi=1001
            else:
                numoggi=int(ultimogg)+1
            file = open('numimg.txt','w') 
            file.seek(0)
            file.write(str(numoggi)) 
            file.close()
        file = open('gg.txt','w') 
        file.seek(0)
        file.write(oggi) 
        file.close()
        if numoggi>1019:
            miraglio = Image(source = 'IMMAGO/%s.zip'% numoggi,keep_ratio = False,keep_data = True,size_hint=(1,1))
        else:
            miraglio = Image(source = 'IMMAGO/%s.jpg'% numoggi,keep_ratio = False,keep_data = True,size_hint=(1,1))
        my_button1 = exitt()
        my_button1.size_hint = (0.075, 0.075)
        my_button1.pos_hint= {'right': .97,'top':.97}
        my_button1.bind(on_release=self.changer)
        my_box1.add_widget(miraglio)
        my_box1.add_widget(my_button1)
        self.add_widget(my_box1)
    def changer(self,*args):
        App.get_running_app().stop()



class TestApp(App):
    def build(self):
        self.icon = 'icona.png'
        my_screenmanager = ScreenManager()
        my_screenmanager= ScreenManager(transition=FadeTransition())
        screen1 = ScreenOne(name='screen1')
        screen3 = ScreenThree(name='screen3')
        my_screenmanager.add_widget(screen1)
        my_screenmanager.add_widget(screen3)
        return my_screenmanager

if __name__ == '__main__':
    TestApp().run()

Logcat报告此错误: I/python (24189): [ERROR ] [Image ] Error loading texture killbtn.zip。 我错过了什么?不管怎样,谢谢!

0 个答案:

没有答案