Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NewsScreen(Screen): #
- news_document = ObjectProperty()
- def __init__(self, **kwargs):
- super(NewsScreen, self).__init__(**kwargs)
- Clock.schedule_once(self.my_init, 0)
- def my_init(self, dt):
- self.news_document.height = dp(size_per_news * (len(news[0:startup_number])) + self.news_document.spacing)
- for item in news[0:startup_number]:
- card = MDCard(size_hint_y=None, height=dp(size_per_news))
- global_layout = GridLayout(cols=2, spacing=dp(20))
- text_layout = BoxLayout(orientation='vertical')
- title = MDLabel(text=item['title'], font_style='Subhead', theme_text_color='Primary',
- size_hint_y=.2)
- body = MDLabel(text=item.values()[0]['value'][0:substring_chars], theme_text_color='Primary',
- size_hint_y=.8)
- text_layout.add_widget(title)
- text_layout.add_widget(body)
- a = Image(source='image-loading.gif')
- global_layout.add_widget(a)
- proxy_image = Loader.image('http://ligafutsal.com.br/wp-content/uploads/2016/04/acbf.jpg')
- proxy_image.bind(on_load=partial(self._image_loaded, a))
- global_layout.add_widget(text_layout)
- card.add_widget(global_layout)
- self.news_document.add_widget(card)
- def _image_loaded(self, a, proxy_image):
- if proxy_image.image.texture:
- print 'img loaded'
- a.texture = proxy_image.image.texture
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement