2011-07-05 08:59:10 +00:00
|
|
|
'''
|
|
|
|
Asynchronous image loading
|
|
|
|
==========================
|
|
|
|
|
|
|
|
Test of the widget AsyncImage.
|
|
|
|
We are just putting it in a CenteredAsyncImage for beeing able to center the
|
|
|
|
image on screen without doing upscale like the original AsyncImage.
|
|
|
|
'''
|
|
|
|
|
|
|
|
from kivy.app import App
|
|
|
|
from kivy.uix.image import AsyncImage
|
|
|
|
from kivy.lang import Builder
|
|
|
|
|
|
|
|
|
|
|
|
Builder.load_string('''
|
|
|
|
<CenteredAsyncImage>:
|
|
|
|
size: self.texture_size
|
|
|
|
size_hint: None, None
|
|
|
|
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
|
class CenteredAsyncImage(AsyncImage):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class TestAsyncApp(App):
|
|
|
|
def build(self):
|
|
|
|
return CenteredAsyncImage(
|
2013-02-16 17:51:07 +00:00
|
|
|
source='http://kivy.org/funny-pictures-cat-is-expecting-you.jpg')
|
2011-07-05 08:59:10 +00:00
|
|
|
|
2012-07-29 19:43:01 +00:00
|
|
|
if __name__ == '__main__':
|
2011-07-05 08:59:10 +00:00
|
|
|
TestAsyncApp().run()
|