rickyc81

Main2

Sep 23rd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.66 KB | None | 0 0
  1. from kivy.lang import Builder
  2. from kivy.uix.boxlayout import BoxLayout
  3. from kivymd.app import MDApp
  4. from kivymd.uix.dialog import MDDialog
  5.  
  6.  
  7. KV = '''
  8.  
  9. NavigationLayout:
  10.  
  11.    ScreenManager:
  12.  
  13.        Screen:
  14.          
  15.  
  16.            MDToolbar:
  17.                id: toolbar
  18.                pos_hint: {"top": 1}
  19.                elevation: 5
  20.                title: "WEATHER_STATION"
  21.                left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
  22.  
  23.            GridLayout:
  24.                rows: 4
  25.  
  26.            MDNavigationDrawer:
  27.                id: nav_drawer
  28.  
  29.                BoxLayout:
  30.                    orientation: "vertical"
  31.                    padding: "8dp"
  32.                    spacing: "8dp"
  33.  
  34.                    AnchorLayout:
  35.                        anchor_x: "left"
  36.                        size_hint_y: None
  37.                        height: avatar.height
  38.  
  39.                        Image:
  40.                            id: avatar
  41.                            size_hint: None, None
  42.                            size: "100dp", "100dp"
  43.                            source: "./img/pwa_icon_512x512.png"
  44.  
  45.                    MDLabel:
  46.                        text: "WeatherStation Pro 1.0.0"
  47.                        font_style: "Button"
  48.                        size_hint_y: None
  49.                        height: self.texture_size[1]
  50.  
  51.                    MDLabel:
  52.                        text: "riccardo.cosenza@gmail.com"
  53.                        font_style: "Caption"
  54.                        size_hint_y: None
  55.                        height: self.texture_size[1]
  56.  
  57.                    ScrollView:
  58.  
  59.                        MDList:
  60.  
  61.                            OneLineAvatarListItem:
  62.                                text: "Informazioni"
  63.                                on_press: app.showInfoDialog()
  64.  
  65.                                IconLeftWidget:
  66.                                    icon: "information-outline"
  67.                                    
  68.  
  69.                            OneLineAvatarListItem:
  70.                                text: "Contattaci"
  71.                                on_press: app.showcontactDialog()
  72.  
  73.                                IconLeftWidget:
  74.                                    icon: "card-account-details-outline"
  75.  
  76. '''
  77.  
  78.  
  79. class TestNavigationDrawer(MDApp):
  80.  
  81.     contactDialog = None
  82.     infoDialog = None
  83.  
  84.     def build(self):
  85.         return Builder.load_string(KV)
  86.  
  87.     def showInfoDialog(self):
  88.         if not self.infoDialog:
  89.             self.infoDialog = MDDialog(
  90.                 title = "Informazioni APP",
  91.                 text = "Made with KivyMD @2020",
  92.                 auto_dismiss = True,
  93.                 pos_hint = {'center_x': .5, 'center_y': .5},
  94.                 radius=[20, 20, 20, 20],
  95.             )
  96.         self.infoDialog.open()
  97.  
  98.     def showcontactDialog(self):
  99.         if not self.contactDialog:
  100.             self.contactDialog = MDDialog(
  101.                 title = "I nostri contatti",
  102.                 text = "riccardo.cosenza81@gmail.com",
  103.                 auto_dismiss = True,
  104.                 pos_hint = {'center_x': .5, 'center_y': .5},
  105.                 radius=[20, 20, 20, 20],
  106.             )
  107.         self.contactDialog.open()
  108.  
  109.  
  110.     def getData(self):
  111.         endpoint = "http://weatherstation.ddnsfree.com/libs/getData.php"
  112.         self.res_request = UrlRequest(endpoint, on_success = self.printData)
  113.  
  114.     #Momentaneo
  115.     def printData(self, request, response):
  116.         responseToJson = json.loads(response)
  117.         data = responseToJson["TIMESTAMP_LOCAL"]
  118.         print(responseToJson["TIMESTAMP_LOCAL"])
  119.         #print(self.root.ids.tabs)
  120.  
  121.  
  122. TestNavigationDrawer().run()
Add Comment
Please, Sign In to add comment