Created
May 26, 2011 05:40
-
-
Save hansent/992613 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from glob import glob | |
| import kivy | |
| kivy.require('1.0.0') | |
| from kivy.app import App | |
| from kivy.uix.image import Image | |
| from kivy.uix.button import Button | |
| from kivy.uix.boxlayout import BoxLayout | |
| from kivy.cache import Cache | |
| from kivy.clock import Clock | |
| Cache.register('kv.texture', timeout=5) | |
| def print_cache(*args): | |
| Cache.print_usage() | |
| class MyApp(App): | |
| def next_image(self): | |
| for i in range(10): | |
| src = self.file_list.pop(0) | |
| self.image.source = src | |
| self.file_list.append(src) | |
| #print self.image.texture | |
| #gc.collect() | |
| def build(self): | |
| self.file_list = glob('cache/products/1280*') | |
| self.image = Image() | |
| self.button1 = Button(text='Hello World') | |
| self.button = Button(text='Load Image', on_press=self.next_image) | |
| layout = BoxLayout() | |
| layout.add_widget(self.button1) | |
| layout.add_widget(self.button) | |
| Clock.schedule_interval(print_cache, 1) | |
| return layout | |
| if __name__ in ('__android__', '__main__'): | |
| MyApp().run() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok, allocate memory for initial texture