Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Homepage(Screen):
- def __init__(self, **kwargs):
- super().__init__(**kwargs)
- self.t = None # used to hold thread
- def on_enter(self,*args):
- if self.t: # only allow 1 thread to be created
- return
- self.t =threading.Thread(target=self.fetch_data)
- self.t.start()
- def fetch_data(self):
- time.sleep(1)
- try:
- #self.ids.screen_man.current = 'showdata'
- # getting data from real-time database
- self.firebase = firebase.FirebaseApplication('https://lexconnectionsapp-default-rtdb.firebaseio.com/', None)
- self.result = self.firebase.get('lexconnectionsapp-default-rtdb/products', None)
- # data i fetched from my database
- self.data = self.result
- products = [item for item in self.data.values()] # ignore primary key, get the inner dicts
- for product in products:
- sc = ShowCard(**product) # same as Showcard(description=product['description'],...)
- self.ids.prduct_grid.add_widget(sc)
- except Exception as error:
- print (str(error))
- # toast(str(error) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement