Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from firebase import firebase
- from firebase_admin import db
- from kivymd.app import MDApp
- from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
- from kivy.core.window import Window
- from kivy.lang import Builder
- Window.size = 400, 700
- gt="""
- Managert:
- MainScreen:
- <MainScreen>:
- name:'home'
- MDBoxLayout:
- orientation:'vertical'
- padding:20
- spacing:10
- MDLabel:
- text:"Fetched Data"
- bold:True
- adaptive_height:True
- font_style:'H4'
- ScrollView:
- MDList:
- Showcard:
- on_press:print('ga')
- #card i want to populate to show data
- <Showcard@MDCard>
- id:showdatacard
- orientation:'vertical'
- ripple_behavior:True
- size_hint:1,None
- height:250
- elevation:25
- MDGridLayout:
- cols:2
- AsyncImage:
- source:"https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/phone.jpg?alt=media&token=e65f6cb9-7aeb-40bd-85e9-bbacf12b56a2"
- MDBoxLayout:
- orientation:'vertical'
- MDLabel:
- text:'Single Steel door Original'
- bold:True
- color:app.theme_cls.primary_color
- font_name:'fonts/popins.ttf'
- MDLabel:
- text:'This single security door has alarm '
- MDLabel:
- text:'ush 500,000'
- color:app.theme_cls.primary_color
- font_name:'fonts/popins.ttf'
- MDSeparator:
- MDBoxLayout:
- MDIconButton:
- icon:'cart'
- tooltip_text:'add cart'
- MDIconButton:
- icon:'heart'
- tooltip_text:'like'
- on_press:root.addtofavourite
- """
- class Managert(ScreenManager):
- pass
- class MainScreen(Screen):
- def on_enter(self):
- #getting data from real-time database
- self.firebase=firebase.FirebaseApplication('https://lexconnectionsapp-default-rtdb.firebaseio.com/',None)
- print('connecting........')
- self.result= self.firebase.get('lexconnectionsapp-default-rtdb/products',None)
- print((self.result))
- print('show here iam')
- # data i fetched from my database
- self.data={
- "product2": {
- "desciption": "best tv in uganda",
- "image": "https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/electronics.jpg?alt=media&token=f367e838-64a7-46bf-9134-f9dc4f25cc19",
- "name": "television",
- "price": "250,000"
- },
- "product3": {
- "description": "iphone pro best",
- "image": "https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/phone.jpg?alt=media&token=e65f6cb9-7aeb-40bd-85e9-bbacf12b56a2",
- "name": "phones",
- "price": "1000,000"
- },
- "product4": {
- "description": "best jobs ever",
- "image": "https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/jobs.jpg?alt=media&token=47c976fe-7832-41ff-97d9-9f1860613b3e",
- "name": "jobs",
- "price": "ugx 200,00"
- }
- }
- class FetchdataApp(MDApp):
- def build(self):
- return Builder.load_string(gt)
- # i was trying to post that data to the database
- '''firebase=firebase.FirebaseApplication('https://lexconnectionsapp-default-rtdb.firebaseio.com/',None)
- #importing data
- data={
- 'Name':'Ford',
- 'image':'gs://lexconnectionsapp.appspot.com/car.jpg',
- "price":'ugx:100,000,000',
- "description":'the car is fantastic'
- }
- #post data
- firebase.post('lexconnectionsapp-default-rtdb/products',data)'''
- FetchdataApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement