파이썬[Python]: kivy - Cache 클래스 - kv
kivy.cache 모듈 - Cache 클래스(class)
/// 설명
유일한 key로 파이썬의 객체를 저장할 수 있습니다. 객체의 수(limit)와 시간(timeout)으로 캐시를 제어할 수 있습니다.
참고: animation to gesture 모듈 목록
※ 형식
Cache
reference
https://kivy.org/doc/stable/api-kivy.cache.html
참고: animation to gesture 모듈 목록
※ 형식
Cache
reference
https://kivy.org/doc/stable/api-kivy.cache.html
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47  | import kivy kivy.require('2.0.0') from kivy.app import App from kivy.core.window import Window from kivy.cache import Cache from kivy.lang import Builder Window.clearcolor = (.6, 1, .8, 1) Window.size = (563, 1001) Window.top, Window.left = 30, 700 kv = ''' BoxLayout:     id: id_bl     orientation: 'vertical'     Label:         id: id_lb         text: 'will be disappeared'         color: 'black'     Button:         text: 'after 3 seconds'         on_press: app._bt_press(self, id_bl, id_lb) ''' class FantasticApp(App):     def _bt_press(self, bt_instance, bl, lb):         print(Cache.get_lastaccess('test_cache', self.key))         lb_cache = Cache.get('test_cache', self.key)         if lb_cache is None:             bl.remove_widget(lb)             bt_instance.text = 'the Cache is gone'     def on_start(self):         Cache.register('test_cache', timeout=3)         self.key = key = id(self.root.ids.id_lb)         Cache.append('test_cache', key, self.root.ids.id_lb)     def build(self):         return Builder.load_string(kv) FantasticApp().run()  | cs | 
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기