Advertisement
jevixlugya

Untitled

Feb 22nd, 2023
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.65 KB | None | 0 0
  1. from firebase import firebase
  2. from firebase_admin import db
  3. from kivymd.app import MDApp
  4. from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
  5. from kivy.core.window import Window
  6. from kivy.lang import Builder
  7. Window.size = 400, 700
  8. gt="""
  9. Managert:
  10.    MainScreen:
  11. <MainScreen>:
  12.     name:'home'
  13.     MDBoxLayout:
  14.         orientation:'vertical'
  15.         padding:20
  16.         spacing:10
  17.         MDLabel:
  18.             text:"Fetched Data"
  19.             bold:True
  20.             adaptive_height:True
  21.             font_style:'H4'
  22.  
  23.         ScrollView:
  24.             MDList:
  25.                 Showcard:
  26.                     on_press:print('ga')
  27.  
  28.  
  29. #card i want to  populate to show data
  30. <Showcard@MDCard>
  31.    id:showdatacard
  32.    orientation:'vertical'                                  
  33.    ripple_behavior:True
  34.    size_hint:1,None
  35.    height:250
  36.    elevation:25
  37.    MDGridLayout:
  38.        cols:2
  39.        AsyncImage:
  40.            source:"https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/phone.jpg?alt=media&token=e65f6cb9-7aeb-40bd-85e9-bbacf12b56a2"
  41.        MDBoxLayout:
  42.            orientation:'vertical'
  43.          
  44.            MDLabel:
  45.                text:'Single Steel door Original'
  46.                bold:True
  47.                color:app.theme_cls.primary_color
  48.                font_name:'fonts/popins.ttf'
  49.            MDLabel:
  50.                text:'This single security door has alarm  '    
  51.            
  52.            MDLabel:
  53.                text:'ush 500,000'
  54.                color:app.theme_cls.primary_color
  55.                font_name:'fonts/popins.ttf'
  56.  
  57.            MDSeparator:
  58.  
  59.            MDBoxLayout:
  60.                MDIconButton:
  61.                    icon:'cart'
  62.                    tooltip_text:'add cart'
  63.              
  64.                MDIconButton:
  65.                    icon:'heart'
  66.                    tooltip_text:'like'
  67.                    on_press:root.addtofavourite
  68. """
  69. class Managert(ScreenManager):
  70.     pass
  71.  
  72. class MainScreen(Screen):
  73.     def on_enter(self):
  74.         #getting data from real-time database
  75.         self.firebase=firebase.FirebaseApplication('https://lexconnectionsapp-default-rtdb.firebaseio.com/',None)
  76.         print('connecting........')
  77.  
  78.         self.result= self.firebase.get('lexconnectionsapp-default-rtdb/products',None)
  79.         print((self.result))       
  80.         print('show here iam')
  81.         # data i fetched from my database
  82.         self.data={
  83.         "product2": {
  84.             "desciption": "best tv in uganda",
  85.             "image": "https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/electronics.jpg?alt=media&token=f367e838-64a7-46bf-9134-f9dc4f25cc19",
  86.             "name": "television",
  87.             "price": "250,000"
  88.         },
  89.         "product3": {
  90.             "description": "iphone pro best",
  91.             "image": "https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/phone.jpg?alt=media&token=e65f6cb9-7aeb-40bd-85e9-bbacf12b56a2",
  92.             "name": "phones",
  93.             "price": "1000,000"
  94.         },
  95.         "product4": {
  96.             "description": "best jobs ever",
  97.             "image": "https://firebasestorage.googleapis.com/v0/b/lexconnectionsapp.appspot.com/o/jobs.jpg?alt=media&token=47c976fe-7832-41ff-97d9-9f1860613b3e",
  98.             "name": "jobs",
  99.             "price": "ugx 200,00"
  100.         }
  101.     }      
  102.  
  103. class FetchdataApp(MDApp):
  104.     def build(self):
  105.         return Builder.load_string(gt)
  106.  
  107.  
  108. # i was trying to post that data to the database
  109.  
  110. '''firebase=firebase.FirebaseApplication('https://lexconnectionsapp-default-rtdb.firebaseio.com/',None)
  111. #importing data
  112. data={
  113.     'Name':'Ford',
  114.     'image':'gs://lexconnectionsapp.appspot.com/car.jpg',
  115.     "price":'ugx:100,000,000',
  116.     "description":'the car is fantastic'
  117.  
  118.  
  119. }
  120. #post data
  121. firebase.post('lexconnectionsapp-default-rtdb/products',data)'''
  122.  
  123. FetchdataApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement