Advertisement
2n2u

Untitled

Apr 12th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. class NewsScreen(Screen):  #
  2.     news_document = ObjectProperty()
  3.  
  4.     def __init__(self, **kwargs):
  5.         super(NewsScreen, self).__init__(**kwargs)
  6.         Clock.schedule_once(self.my_init, 0)
  7.  
  8.     def my_init(self, dt):
  9.         self.news_document.height = dp(size_per_news * (len(news[0:startup_number])) + self.news_document.spacing)
  10.  
  11.         for item in news[0:startup_number]:
  12.             card = MDCard(size_hint_y=None, height=dp(size_per_news))
  13.             global_layout = GridLayout(cols=2, spacing=dp(20))
  14.             text_layout = BoxLayout(orientation='vertical')
  15.             title = MDLabel(text=item['title'], font_style='Subhead', theme_text_color='Primary',
  16.                             size_hint_y=.2)
  17.             body = MDLabel(text=item.values()[0]['value'][0:substring_chars], theme_text_color='Primary',
  18.                            size_hint_y=.8)
  19.             text_layout.add_widget(title)
  20.             text_layout.add_widget(body)
  21.             a = Image(source='image-loading.gif')
  22.             global_layout.add_widget(a)
  23.             proxy_image = Loader.image('http://ligafutsal.com.br/wp-content/uploads/2016/04/acbf.jpg')
  24.             proxy_image.bind(on_load=partial(self._image_loaded, a))
  25.             global_layout.add_widget(text_layout)
  26.             card.add_widget(global_layout)
  27.             self.news_document.add_widget(card)
  28.  
  29.     def _image_loaded(self, a, proxy_image):
  30.         if proxy_image.image.texture:
  31.             print 'img loaded'
  32.             a.texture = proxy_image.image.texture
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement