Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.lang import Builder
- from kivy.uix.boxlayout import BoxLayout
- from kivymd.app import MDApp
- from kivymd.uix.dialog import MDDialog
- KV = '''
- NavigationLayout:
- ScreenManager:
- Screen:
- MDToolbar:
- id: toolbar
- pos_hint: {"top": 1}
- elevation: 5
- title: "WEATHER_STATION"
- left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
- GridLayout:
- rows: 4
- MDNavigationDrawer:
- id: nav_drawer
- BoxLayout:
- orientation: "vertical"
- padding: "8dp"
- spacing: "8dp"
- AnchorLayout:
- anchor_x: "left"
- size_hint_y: None
- height: avatar.height
- Image:
- id: avatar
- size_hint: None, None
- size: "100dp", "100dp"
- source: "./img/pwa_icon_512x512.png"
- MDLabel:
- text: "WeatherStation Pro 1.0.0"
- font_style: "Button"
- size_hint_y: None
- height: self.texture_size[1]
- MDLabel:
- text: "riccardo.cosenza@gmail.com"
- font_style: "Caption"
- size_hint_y: None
- height: self.texture_size[1]
- ScrollView:
- MDList:
- OneLineAvatarListItem:
- text: "Informazioni"
- on_press: app.showInfoDialog()
- IconLeftWidget:
- icon: "information-outline"
- OneLineAvatarListItem:
- text: "Contattaci"
- on_press: app.showcontactDialog()
- IconLeftWidget:
- icon: "card-account-details-outline"
- '''
- class TestNavigationDrawer(MDApp):
- contactDialog = None
- infoDialog = None
- def build(self):
- return Builder.load_string(KV)
- def showInfoDialog(self):
- if not self.infoDialog:
- self.infoDialog = MDDialog(
- title = "Informazioni APP",
- text = "Made with KivyMD @2020",
- auto_dismiss = True,
- pos_hint = {'center_x': .5, 'center_y': .5},
- radius=[20, 20, 20, 20],
- )
- self.infoDialog.open()
- def showcontactDialog(self):
- if not self.contactDialog:
- self.contactDialog = MDDialog(
- title = "I nostri contatti",
- text = "riccardo.cosenza81@gmail.com",
- auto_dismiss = True,
- pos_hint = {'center_x': .5, 'center_y': .5},
- radius=[20, 20, 20, 20],
- )
- self.contactDialog.open()
- def getData(self):
- endpoint = "http://weatherstation.ddnsfree.com/libs/getData.php"
- self.res_request = UrlRequest(endpoint, on_success = self.printData)
- #Momentaneo
- def printData(self, request, response):
- responseToJson = json.loads(response)
- data = responseToJson["TIMESTAMP_LOCAL"]
- print(responseToJson["TIMESTAMP_LOCAL"])
- #print(self.root.ids.tabs)
- TestNavigationDrawer().run()
Add Comment
Please, Sign In to add comment