欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python kivy 异步加载图片.2020-12-09

程序员文章站 2022-07-05 20:49:45
from kivy.app import Appfrom kivy.uix.gridlayout import GridLayoutfrom kivy.uix.label import Labelfrom kivy.uix.image import Image, AsyncImage# AsyncImage异步图像,图片加载速度更快labelStr = '''[b]Kivy Gif[/b] test test test'''class TestApp(App): d....
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.image import Image, AsyncImage

# AsyncImage异步图像,图片加载速度更快

labelStr = '''
[b]Kivy Gif[/b]
    test test test
'''


class TestApp(App):
    def build(self):
        self.title = 'Kivy Gif'

        layout = GridLayout(cols=1)
        lab = Label(text=labelStr, markup=True,
                    font_size='30sp', size_hint_y=None, height=100)
        # img = Image(source='Gif1.gif', anim_delay=1.0 / 24)
        img = AsyncImage(source='Gif1.gif', anim_delay=1.0 / 24)
        # 异步图像加载
        # 重新定义帧率:每秒24帧

        layout.add_widget(lab)
        layout.add_widget(img)
        return layout


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

python kivy 异步加载图片.2020-12-09

 

本文地址:https://blog.csdn.net/u012336596/article/details/110921781

相关标签: python入门笔记