· 4 years ago · Feb 20, 2021, 01:52 AM
1import datetime
2import json
3import sqlite3 as sql
4import time
5
6from kivy.clock import Clock
7from kivy.lang import Builder
8from kivy.properties import StringProperty
9from kivy.uix.boxlayout import BoxLayout
10from kivy.uix.screenmanager import Screen
11from kivymd.app import MDApp
12from kivymd.uix.boxlayout import MDBoxLayout
13from kivymd.uix.button import MDFlatButton
14from kivymd.uix.dialog import MDDialog
15from kivymd.uix.expansionpanel import MDExpansionPanel, MDExpansionPanelTwoLine
16from kivymd.uix.list import IRightBodyTouch, MDList
17
18from news import News
19
20
21class NewsLayout(BoxLayout):
22 title = StringProperty()
23 picture = StringProperty(allownone=True)
24 description = StringProperty(allownone=True)
25
26
27class Content(MDList):
28 pass
29
30
31class RecordLine(MDBoxLayout):
32 text = StringProperty()
33
34
35class InformationDialog(MDDialog):
36 pass
37
38
39class MainMenuScreen(Screen):
40 pass
41
42
43class InputScreen(Screen):
44 pass
45
46
47class RestingHeartRateScreen(Screen):
48 pass
49
50
51class ResultObeseScreen(Screen):
52 pass
53
54
55class ResultNormalScreen(Screen):
56 pass
57
58
59class ResultOverweightScreen(Screen):
60 pass
61
62
63class ResultUnderweightScreen(Screen):
64 pass
65
66
67class LocationSearchScreen(Screen):
68 pass
69
70
71class LocationResultScreen(Screen):
72 pass
73
74
75class HistoryScreen(Screen):
76 pass
77
78
79class DemoApp(MDApp):
80
81 # conn = sql.connect('USERINFO.db')
82 # cur = conn.cursor()
83 # cur.execute(""" CREATE TABLE IF NOT EXISTS results (
84 # UID INTEGER PRIMARY KEY AUTOINCREMENT,
85 # NAME VARCHAR(50),
86 # RESULT INT,
87 # DATE_TIME TEXT DEFAULT CURRENT_TIMESTAMP)
88 # """)
89 # cur.execute(""" CREATE TABLE IF NOT EXISTS information (
90 # id INTEGER PRIMARY KEY AUTOINCREMENT,
91 # fname VARCHAR(50),
92 # height INT,
93 # weight INT,
94 # age INT,
95 # heartrate INT)
96 # """)
97 # conn.commit()
98 # conn.close()
99
100 def __init__(self, **kwargs):
101 super().__init__(**kwargs)
102 self.news = News() # create the Class instance
103 self.news.get_news() # pull a list of stories from the web
104 self.i = 0 # index for moving through the
105 self.list_items = [] # Dictionary where the items is stored
106 self.counter = 0
107 self.counting = {'Item counter': self.counter}
108 self.dialog = None
109 self.selected_category = None
110 self.selected_rec = None
111 self.card_file = \
112 [{'Category': 'Barangay ALABANG',
113 'Record': [
114 {'title': 'Alabang Medical Clinic ( MAIN )',
115 'Details': [
116 ' ADDRESS: \n 297 Montillano St, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 0680']},
117 {'title': 'Alabang Medical Center, Alabang Zapote road',
118 'Details': [
119 ' ADDRESS: \n Ayala Life-FGU Center, Zapote Road Corner Acacia Avenue Madrigal Business Park, Ayala Alabang, Muntinlupa \n TELEPHONE NUMBER: \n 0998 855 9221']},
120 {'title': 'Asian Hospital and Medical Center',
121 'Details': [
122 ' ADDRESS: \n 2205 Civic Dr, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8771 9000']},
123 {'title': 'Aventus Medical Care, Inc. - Alabang Clinic',
124 'Details': [
125 ' ADDRESS: \n 2/F Sycamore ARCS 1 Building Buencamino Street corner Alabang - Zapote Road Madrigal Business Park, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8556 3598']},
126 {'title': 'Healthway Medical Festival Mall',
127 'Details': [
128 ' ADDRESS: \n 2nd Floor, Pixie Forest Entrance, Filinvest Ave, Filinvest City, Muntinlupa \n TELEPHONE NUMBER: \n (02) 751 4929']},
129 {'title': 'Healthfirst clinic ALABANG',
130 'Details': [
131 ' ADDRESS: \n G/F, South Supermarket, Filinvest Ave., Filinvest Corporate City \n TELEPHONE NUMBER: \n (+632) 8 821 1423 | 0917 842 8214']},
132 {'title': 'Ospital ng Muntinlupa ( OSMUN )',
133 'Details': [
134 ' ADDRESS: \n Civic Dr, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8771 0457']},
135 {'title': 'St. Michaels Medical Center',
136 'Details': [
137 ' ADDRESS: \n Starmall Alabang, South Super Hwy, Alabang, Muntinlupa\n TELEPHONE NUMBER: \n 0921 624 4418']},
138 {'title': 'San Roque Medical Clinic',
139 'Details': [' ADDRESS: \n Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 2950']},
140 {'title': 'Megason Diagnostic Clinic',
141 'Details': [' ADDRESS: \nAlabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8809 9044']},
142 {'title': 'Tokyo Healthlink 東京ヘルスリンク - Alabang',
143 'Details': [
144 ' ADDRESS: \n Molito Complex, Madrigal Ave, Ayala Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8772 2678']},
145 {'title': 'Research Institute for Tropical Medicine',
146 'Details': [
147 ' ADDRESS: \n Filinvest Corporate City, 9002 Research Dr, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8807 2631']},
148 ]},
149 {'Category': 'Barangay BAYANAN',
150 'Record': [
151 {'title': 'Silverio Medical Clinic',
152 'Details': [
153 ' ADDRESS: \n 233g National Road, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8862 0223']},
154 {'title': 'Bayanan Health Center (Annex)',
155 'Details': [
156 ' ADDRESS: \n Block 2, Purok 1, 292 M Dolleton St, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8862 0124']},
157 {'title': 'Bayanan Medical Clinic, X-Ray and Laboratory Services',
158 'Details': [
159 ' ADDRESS: \n 231 National Road, Bayanan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 5861']},
160 {'title': 'El Natividad Medical And Maternity Clinic',
161 'Details': [
162 ' ADDRESS: \n 214 National Road, Muntinlupa \n TELEPHONE NUMBER: \n 0923 701 5164']},
163 ]},
164 {'Category': 'Barangay CUPANG',
165 'Record': [
166 {'title': 'Hillside General Hospital',
167 'Details': [
168 ' ADDRESS: \n Km. 23, West Service Road, Cupang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 3958']},
169 {'title': 'Alabang Medical Center',
170 'Details': [
171 ' ADDRESS: \n 8 Corregidor, Cupang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8850 8719']},
172 {'title': 'Cupang Health Center',
173 'Details': [
174 ' ADDRESS: \n Barangay Hall, Beside Cupang, Manuel L. Quezon, Cupang, Muntinlupa \n TELEPHONE NUMBER: \n --']},
175 ]},
176 {'Category': 'Barangay POBLACION',
177 'Record': [
178 {'title': 'Albia Medical & Diagnostic Clinic',
179 'Details': [
180 ' ADDRESS: \n 93 Rizal St, Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n (02)8461204']},
181 {'title': 'Babaran Echavez Medical And Psychiatric Clinic',
182 'Details': [
183 ' ADDRESS: \n 1125 Amparo Corner Sto Nino Street, Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 3066']},
184 {'title': 'MCC De La Merced Maternity And Childrens Clinic',
185 'Details': [
186 ' ADDRESS: \n 92 Rizal St, Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 3944']},
187 {'title': 'Mauricestela Medical Clinic',
188 'Details': [
189 ' ADDRESS: \n 212 Pedro Diaz St, Poblacion, Muntinlupa, 1776 Metro Manila \n TELEPHONE NUMBER: \n (02) 8862 2117']},
190 {'title': 'Poblacion Health Center Main',
191 'Details': [
192 ' ADDRESS: \n Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n NONE']},
193 ]},
194 {'Category': 'Barangay PUTATAN',
195 'Record': [
196 {'title': 'Alabang Medical Clinic - Muntinlupa Branch',
197 'Details': [
198 ' ADDRESS: \n 1 National Highway, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 1779']},
199 {'title': 'IMS Wellth Care, Inc.',
200 'Details': [
201 ' ADDRESS: \n 49 National Road, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 1592']},
202 {'title': 'Medical Center Muntinlupa',
203 'Details': [
204 ' ADDRESS: \n National Road, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n 8620162']},
205 {'title': 'Muntinlupa Doctors Clinic',
206 'Details': [
207 ' ADDRESS: \n 1 National Road, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 2718']},
208 {'title': 'Medcare Multi Specialty',
209 'Details': [
210 ' ADDRESS: \n 84-I, National Road, Barangay Putatan, Muntinlupa \n TELEPHONE NUMBER: \n 0922 857 4180']},
211 ]},
212 {'Category': 'Barangay SUCAT',
213 'Record': [
214 {'title': 'Sucat Health Center',
215 'Details': [
216 ' ADDRESS: \n 624 Dir. A. Bunye, Sucat, Muntinlupa \n TELEPHONE NUMBER: \n NONE']},
217 ]},
218 {'Category': 'Barangay TUNASAN',
219 'Record': [
220 {'title': 'Beato-Cauilan Hospital',
221 'Details': [
222 ' ADDRESS: \n Manila S Rd, Tunasan, Muntinlupa \n TELEPHONE NUMBER: \n +632 861-5284']},
223 ]}]
224
225 def on_start(self):
226 Clock.schedule_interval(self.update_news, 5) # every 5 seconds, show the next story
227 for category in self.card_file:
228 panel = MDExpansionPanel(icon="scr2.png", content=Content(),
229 panel_cls=MDExpansionPanelTwoLine(text=category['Category'],
230 secondary_text="Tap to view Hospitals"))
231 self.root.ids.scr_mngr.get_screen('locsearch').ids.rlist.add_widget(panel)
232 for rec in category['Record']:
233 rw = RecordLine(text=rec['title'])
234 print(rec['title'])
235 self.root.ids.scr_mngr.get_screen('locsearch').ids.rlist.children[0].content.add_widget(rw)
236
237
238 def showinfo(self, cat, r):
239 close_button = MDFlatButton(text="Done", on_release=self.close_dialog)
240 ingredients = self.ingredients_list(cat, r)
241 ingredients_text = ''
242 for ingredient in ingredients:
243 ingredients_text += ingredient
244 self.dialog = InformationDialog(size_hint=(0.8, 0.8), text=ingredients_text, auto_dismiss=True,
245 buttons=[close_button])
246 self.dialog.open()
247
248 def ingredients_list(self, selected_cat, selected_r):
249 self.selected_rec = selected_r
250 self.selected_category = selected_cat
251 for category in self.card_file:
252 if category['Category'] == selected_cat:
253 for rec in category['Record']:
254 if rec['title'] == selected_r:
255 return rec['Details']
256
257 def on_stop(self): # Event handler that triggers when the application has finished running
258 # Creates a json file to saved the all the items in dictionary when closing the app
259 with open('saved_list.txt', 'w') as f:
260 json.dump(self.list_items, f)
261
262 class Container(IRightBodyTouch, MDBoxLayout): # This line position widget to the right.
263 adaptive_width = True
264
265 def update_news(self, dt):
266 # this is moving through the list of stories pulled, it does not go back to the web for more content
267 # to get refresed content call self.news.get_news()
268 # Skip stories that don't have a picture and a description
269 if not self.news.headlines[self.i][1] or not self.news.headlines[self.i][2]:
270 self.i = (self.i + 1) % len(self.news.headlines)
271 self.update_news(None) # junk parameter...
272 else:
273 p = self.root.ids.scr_mngr.get_screen('menu').ids.nl # a sort cut to avoid writing self.root.ids.dl 3x
274 p.title = self.news.headlines[self.i][0] # The title
275 p.picture = self.news.headlines[self.i][1] # url to the picture
276 p.description = self.news.headlines[self.i][2]
277 self.i = (self.i + 1) % len(self.news.headlines)
278 bl = BoxLayout()
279 self.root.ids.scr_mngr.get_screen('menu').ids.nl.add_widget(bl)
280
281 def save_data(self):
282 conn = sql.connect('USERINFO.db')
283 cur = conn.cursor()
284 cur.execute(""" INSERT INTO information (fname,height,weight,age,heartrate) VALUES (?,?,?,?,?)""",
285 (self.root.ids.scr_mngr.get_screen('input').ids.fname.text,
286 self.root.ids.scr_mngr.get_screen('input').ids.height.text,
287 self.root.ids.scr_mngr.get_screen('input').ids.weight.text,
288 self.root.ids.scr_mngr.get_screen('input').ids.age.text,
289 self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text))
290 conn.commit()
291 conn.close()
292
293 # def news(self):
294 # url = ('http://newsapi.org/v2/top-headlines?'
295 # 'country=ph&category=health&'
296 # 'apiKey=0a2a06f5a843426ca8384f89111bfe99')
297 # response = requests.get(url)
298 # print(response.json())
299 # news_json = json.loads(response.text)
300 #
301 # count = 4
302 #
303 # for news in news_json['articles']:
304 # if count > 0:
305 # print(str(news['title']), '\n')
306 # print(str(news['description']), "\n")
307 # print(str(news['url']), "\n")
308 # print(str(news['urlToImage']), "\n")
309 # count -= 1
310
311 def result_condition(self):
312 n = int(10000)
313
314 h = int(self.root.ids.scr_mngr.get_screen('input').ids.height.text)
315
316 w = int(self.root.ids.scr_mngr.get_screen('input').ids.weight.text)
317
318 unix = time.time()
319 date = str(datetime.datetime.fromtimestamp(unix).strftime('%Y-%m-%d %H:%M:%S'))
320 answer = (w / h / h) * n
321 print(answer)
322
323 conn = sql.connect('USERINFO.db')
324 cur = conn.cursor()
325 cur.execute(""" INSERT INTO results (NAME,RESULT,DATE_TIME) VALUES (?,?,?)""",
326 (
327 self.root.ids.scr_mngr.get_screen('input').ids.fname.text,
328 answer,
329 date
330 ))
331 conn.commit()
332 conn.close()
333 if answer <= 18.5:
334 self.root.ids.scr_mngr.current = 'underweight'
335 elif 18.6 <= answer <= 24.9:
336 self.root.ids.scr_mngr.current = 'normal'
337 elif 25.0 <= answer <= 29.9:
338 self.root.ids.scr_mngr.current = 'overweight'
339 else:
340 self.root.ids.scr_mngr.current = 'obese'
341
342 def clear_inputs(self): # set each of the inputs to an empty string
343 self.root.ids.scr_mngr.get_screen('input').ids.fname.text = ""
344 self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text = ""
345 self.root.ids.scr_mngr.get_screen('input').ids.age.text = ""
346 self.root.ids.scr_mngr.get_screen('input').ids.height.text = ""
347 self.root.ids.scr_mngr.get_screen('input').ids.weight.text = ""
348
349 def info1_dialog(self):
350 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
351 self.dialog = MDDialog(title="Details",
352 text="Hospitals listed are still operating up-to-date",
353 size_hint=(1, 1),
354 buttons=[close_button])
355 self.dialog.open()
356
357 def show_database(self):
358 conn = sql.connect('USERINFO.db')
359 cur = conn.cursor()
360 cur.execute("""
361 SELECT fname, height, weight, heartrate, RESULT, DATE_TIME
362 FROM information INNER JOIN results
363 ON information.id = results.UID
364 """)
365 output = cur.fetchall()
366 for data in output:
367 print(data)
368
369 def build(self):
370 self.theme_cls.primary_palette = "Yellow"
371 self.theme_cls.theme_style = "Light"
372 screen = Builder.load_file("main.kv")
373 return screen
374
375 def back_screen6(self, obj):
376 self.root.ids.scr_mngr.current = 'menu'
377 self.root.ids.scr_mngr.transition.direction = "right"
378
379 def show_alert_dialog(self):
380 close_button = MDFlatButton(text="Okay",
381 on_release=self.okay)
382 more_button = MDFlatButton(text="Cancel", on_press=self.close_dialog)
383
384 self.dialog = MDDialog(title="Confirmation", text="Confirm Details?",
385 size_hint=(1, 1),
386 buttons=[close_button, more_button])
387 self.dialog.open()
388
389 def result_dialog(self):
390 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
391 self.dialog = MDDialog(title="Where did we get the Results?",
392 text="Results are Determined based on the Details Given by the User",
393 size_hint=(1, 1),
394 buttons=[close_button])
395 self.dialog.open()
396
397 def hakdog(self):
398 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
399 self.dialog = MDDialog(title="Instructions",
400 text="Manual Heartbeat check can be used to determine if you have a normal heart rate for your age. "
401 "If height = feet/inches, Convert to Centimeter (FEET× 30.48 +INCHES× 2.54) ",
402 size_hint=(1, 1),
403 buttons=[close_button])
404 self.dialog.open()
405
406 def show_data(self, *args):
407 if self.root.ids.scr_mngr.get_screen('input').ids.fname.text == "" \
408 or self.root.ids.scr_mngr.get_screen('input').ids.height.text == "" \
409 or self.root.ids.scr_mngr.get_screen('input').ids.weight.text == "" \
410 or self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text == "" \
411 or self.root.ids.scr_mngr.get_screen('input').ids.age.text == "" \
412 or self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text == "":
413 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
414 self.dialog = MDDialog(title="Invalid", text="No item added",
415 size_hint=(1, 1), buttons=[close_button])
416 self.dialog.open()
417 else:
418 self.show_alert_dialog()
419
420 def okay(self, *args):
421 print(self.root.ids.scr_mngr.get_screen('input').ids.fname.text),
422 print(self.root.ids.scr_mngr.get_screen('input').ids.height.text),
423 print(self.root.ids.scr_mngr.get_screen('input').ids.weight.text),
424 print(self.root.ids.scr_mngr.get_screen('input').ids.age.text),
425 print(self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text)
426 self.save_data()
427 self.result_condition()
428 self.clear_inputs()
429 self.dialog.dismiss()
430
431 def close_dialog(self, obj):
432 self.dialog.dismiss()
433
434 def history_screen(self, obj):
435 self.root.ids.scr_mngr.current = 'history'
436 self.root.ids.scr_mngr.transition.direction = "right"
437
438 def location_screen(self, obj):
439 self.root.ids.scr_mngr.current = 'locsearch'
440 self.root.ids.scr_mngr.transition.direction = "left"
441
442 def back_screen(self, obj):
443 self.root.ids.scr_mngr.current = 'menu'
444 self.root.ids.scr_mngr.transition.direction = "left"
445
446 def back2_screen(self, obj):
447 self.root.ids.scr_mngr.current = 'input'
448 self.root.ids.scr_mngr.transition.direction = "right"
449
450 def back3_screen(self, obj):
451 self.root.ids.scr_mngr.current = 'menu'
452 self.root.ids.scr_mngr.transition.direction = "right"
453
454 def back4_screen(self, obj):
455 self.root.ids.scr_mngr.current = 'locsearch'
456 self.root.ids.scr_mngr.transition.direction = "right"
457
458
459DemoApp().run()
460-------------------------------------------------
461from kivy.network.urlrequest import UrlRequest
462from kivy.properties import ListProperty
463from kivy.event import EventDispatcher
464
465
466class News(EventDispatcher):
467 headlines = ListProperty([('Uninitialized', 'Uninitialized', 'No news is good news!')])
468
469 def get_news(self, *args):
470 url = ('http://newsapi.org/v2/top-headlines?'
471 'country=ph&category=health&'
472 'apiKey=0a2a06f5a843426ca8384f89111bfe99')
473 req = UrlRequest(url, self._got_news, on_failure=self.fail, on_error=self.fail)
474
475 def _got_news(self, req, news):
476 print(news)
477 self.headlines.clear()
478 for content in news['articles']:
479 self.headlines.append((content['title'], content['urlToImage'], content['description']))
480
481 def fail(self, instance, value):
482 print('you loose')
483 print(f'Error: {instance}, {value}')
484
485
486if __name__ == '__main__':
487 from kivy.app import App
488 from kivy.clock import Clock
489 from kivy.lang import Builder
490 from kivy.properties import StringProperty
491 from kivy.uix.screenmanager import Screen
492 from kivy.core.window import Window
493
494 import itertools
495 import pprint
496 from textwrap import dedent
497 kv = dedent("""
498 <NewsScreen>:
499 BoxLayout:
500 orientation: 'vertical'
501 Label:
502 size_hint_y: .25
503 text: root.headline
504 text_size: self.size
505 valign: 'center'
506 halign: 'center'
507 # shorten: True
508 # shorten_from: 'right'
509 font_size: 30
510 # padding: 20,20
511 theme_text_color:"ContrastParentBackground"
512 bold: True
513 GridLayout:
514 cols: 2
515 #padding: 20
516 AsyncImage:
517 source: root.headline_image
518 anim_delay: .03334 # 15fps, for gif videos
519 nocache: True
520 Label:
521 #padding_x: 30
522 text: root.description
523 text_size: self.size
524 font_size: 25
525 valign: 'center'
526 theme_text_color:"ContrastParentBackground"
527
528 BoxLayout: # This is the root widget
529 orientation: 'vertical'
530 ScreenManager:
531 id: sm
532 NewsScreen:
533 name: 'news'
534 next: 'weather'
535 duration: 30
536 """)
537
538
539 class NewsScreen(Screen):
540 headline = StringProperty('')
541 headline_image = StringProperty('')
542 description = StringProperty('')
543
544 def __init__(self, **kwargs):
545 super().__init__(**kwargs)
546 self.app = App.get_running_app()
547 self.story = itertools.cycle(self.app.news.headlines)
548 Clock.schedule_once(self.initial_news, 5)
549 self.refresh = Clock.schedule_interval(self.news_next, 15)
550
551 def initial_news(self, *args):
552 self.headline = self.app.news.headlines[0][0] if self.app.news.headlines[0][0] else 'junk'
553 self.headline_image = self.app.news.headlines[0][1] if self.app.news.headlines[0][1] else 'junk'
554 self.description = self.app.news.headlines[0][2] if self.app.news.headlines[0][2] else 'No Description'
555 print(self.headline)
556
557 def news_next(self, *args):
558 n = next(self.story)
559 self.headline = n[0]
560 self.headline_image = n[1] if n[1] is not None else ''
561 self.description = n[2]
562
563 # def on_pre_enter(self, *args):
564 # self.refresh() # start the news refresh schedule
565 #
566 # def on_leave(self, *args):
567 # self.refresh.cancel() # cancel the schedule when we leave the screen
568
569
570 class TestNewsApp(App):
571 news = News()
572
573 def build(self):
574 Window.size = 1500, 303
575 Window.top = 100
576 Window.left = 10
577 return Builder.load_string(kv)
578
579 def on_start(self):
580 self.news.get_news()
581 Clock.schedule_once(self.print_news, 5) # wait for site..
582 print('waiting 5 seconds...')
583
584 def print_news(self, dt):
585 pp = pprint.PrettyPrinter(width=80, compact=True)
586 pp.pprint(self.news.headlines)
587
588
589 TestNewsApp().run()
590----------------------------------------------------------------------
591Screen:
592 ScreenManager:
593 id:scr_mngr
594 MainMenuScreen:
595 name:"menu"
596 InputScreen:
597 name:"input"
598 RestingHeartRateScreen:
599 name:"heartrate"
600 ResultObeseScreen:
601 name:"obese"
602 ResultUnderweightScreen:
603 name:"underweight"
604 ResultOverweightScreen:
605 name:"overweight"
606 ResultNormalScreen:
607 name:"normal"
608 LocationSearchScreen:
609 name:"locsearch"
610 LocationResultScreen:
611 name:"locresult"
612 HistoryScreen:
613 name:"history"
614
615<MainMenuScreen>
616 MDNavigationLayout:
617 ScreenManager:
618 Screen:
619 MDBoxLayout:
620 orientation:'vertical'
621 MDToolbar:
622 title:'MD 24/7'
623 elevation:10
624
625
626 BoxLayout:
627 NewsLayout:
628 id: nl # and in id to access the instance
629 pos_hint:{'center_y':0.3}
630 orientation:'vertical'
631
632 MDBottomAppBar:
633 MDToolbar:
634 icon: "account"
635 type: "bottom"
636 on_action_button:
637 root.manager.current='input'
638 root.manager.transition.direction = "right"
639 left_action_items:[["history",lambda x: app.history_screen("history")]]
640 right_action_items:[["google-earth",lambda x: app.location_screen("locsearch")]]
641
642<NewsLayout>:
643 orientation: 'vertical'
644 orientation: 'vertical'
645 Label:
646 text: root.title
647 text_size: self.size
648 halign: 'center'
649 color : 0,0,0,1
650 AsyncImage:
651 source: root.picture
652 Label:
653 text_size: self.size
654 halign: 'center'
655 text: root.description
656 color: 0,0,0,1
657
658<InputScreen>
659 on_pre_enter: app.clear_inputs()
660 id:information
661 BoxLayout:
662 orientation: 'vertical'
663 MDToolbar:
664 title:'Input Details'
665 elevation:10
666 left_action_items:[["backspace",lambda x:app.back_screen("menu")]]
667 right_action_items:[["head-question",lambda x:app.hakdog()]]
668
669 Widget:
670 MDTextField:
671 id:fname
672 required: True
673 hint_text: "Full name"
674 icon_right:"account"
675 pos_hint: {'center_x': 0.5}
676 size_hint_x: None
677 width: '250dp'
678 helper_text:"Please enter your Registered Name"
679 helper_text_mode:"persistent"
680 Widget:
681 height: 35
682
683 MDTextField:
684 id:height
685 required: True
686 hint_text: "Height"
687 icon_right:"human-male-height"
688 pos_hint: {'center_x': 0.5}
689 size_hint_x: None
690 width: '250dp'
691 helper_text:"Must be in centimeters"
692 helper_text_mode:"persistent"
693 Widget:
694 height:35
695
696 MDTextField:
697 id:weight
698 required: True
699 hint_text: "Weight"
700 icon_right:"weight-kilogram"
701 pos_hint: {'center_x': 0.5}
702 size_hint_x: None
703 width: '250dp'
704 helper_text:"Must be in Kilogram"
705 helper_text_mode:"persistent"
706 Widget:
707 height:35
708
709 MDTextField:
710 id:age
711 hint_text: "Age"
712 required: True
713 icon_right:"cake"
714 pos_hint: {'center_x': 0.5}
715 size_hint_x: None
716 width: '250dp'
717 helper_text:"please enter your age"
718 helper_text_mode:"persistent"
719 Widget:
720 height: 35
721
722 MDTextField:
723 id:heartrate
724 required: True
725 hint_text: "Heartrate"
726 icon_right:"heart-pulse"
727 pos_hint: {'center_x': 0.5}
728 size_hint_x: None
729 width: '250dp'
730 helper_text:"Count the beat on your palm for 60 seconds"
731 helper_text_mode:"persistent"
732 Widget:
733 size_hint_y: None
734
735 MDScreen:
736 MDRectangleFlatButton:
737 mode: "rectangle"
738 text: 'Confirm'
739 pos_hint: {'center_x':0.5, 'center_y':0.8}
740 on_press :
741 app.show_data()
742
743 Widget:
744 size_hint_x: None
745
746<ResultObeseScreen>
747 BoxLayout:
748 orientation: 'vertical'
749 MDToolbar:
750 title:'Result: OBESE'
751 elevation:10
752 right_action_items:[["head-question",lambda x:app.result_dialog()]]
753 Widget:
754
755 MDLabel:
756 text: " People with obesity have increased risk of cardiovascular disease,type 2 diabetes, high blood pressure, and other health conditions. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. A person should consult with their healthcare provider and consider making lifestyle changes through healthy eating and fitness to improve their health indicators. \n TIPS: \n *Change your diet. \n *Consider adding physical activity \n *Medication \n *Consume less “bad” fat and more “good” fat. \n *Consume less processed and sugary foods. \n *Eat more servings of vegetables and fruits \n *Eat plenty of dietary fiber. \n *limit your vices (drinking,smoking,etc)"
757 halign: "left"
758
759 Widget:
760
761 MDScreen:
762 MDRectangleFlatButton:
763 mode: "rectangle"
764 text: 'Go to Main Menu'
765 pos_hint: {'center_x':0.5, 'center_y':0.8}
766 on_press : root.manager.current='menu'
767
768<ResultNormalScreen>
769 BoxLayout:
770 orientation: 'vertical'
771 MDToolbar:
772 title:'Result: NORMAL WEIGHT'
773 elevation:10
774 right_action_items:[["head-question",lambda x:app.result_dialog()]]
775 Widget:
776
777 MDLabel:
778 text :" Maintaining a healthy weight may lower the risk of developing certain health conditions, including cardiovascular disease and type 2 diabetes. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. \n TIPS: \n *Limit what you eat \n *exercise \n *sleep 7-8 hours a day \n *maintain a consistent sleeping routine \n *consider eating more healthy foods \n *limit your vices (drinking,smoking,etc)"
779 halign: "left"
780
781 Widget:
782
783 MDScreen:
784 MDRectangleFlatButton:
785 mode: "rectangle"
786 text: 'Go to Main Menu'
787 pos_hint: {'center_x':0.5, 'center_y':0.8}
788 on_press : root.manager.current='menu'
789
790<ResultOverweightScreen>
791 BoxLayout:
792 orientation: 'vertical'
793 MDToolbar:
794 title:'Result: OVERWEIGHT'
795 elevation:10
796 right_action_items:[["head-question",lambda x:app.result_dialog()]]
797 Widget:
798
799 MDLabel:
800 text: " Being overweight may increase the risk of certain health conditions, including cardiovascular disease, high blood pressure, and type 2 diabetes. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. A person should consult with their healthcare provider and consider making lifestyle changes through healthy eating and fitness to improve their health indicators.Being overweight or fat is having more body fat than is optimally healthy \n TIPS: \n *Eat a high protein breakfast. \n *Avoid sugary drinks and fruit juice \n *Drink water before meals. \n *Choose weight-loss-friendly foods. \n *Eat soluble fiber. \n *Drink coffee or tea. \n *Base your diet on whole foods. \n *Eat slowly. \n *limit your vices (drinking,smoking,etc)"
801 halign: "left"
802
803 Widget:
804
805 MDScreen:
806 MDRectangleFlatButton:
807 mode: "rectangle"
808 text: 'Go to Main Menu'
809 pos_hint: {'center_x':0.5, 'center_y':0.8}
810 on_press : root.manager.current='menu'
811
812<ResultUnderweightScreen>
813 BoxLayout:
814 orientation: 'vertical'
815 MDToolbar:
816 title:'Result: UNDERWEIGHT'
817 elevation:10
818 right_action_items:[["head-question",lambda x:app.result_dialog()]]
819 Widget:
820
821 MDLabel:
822 text: " Being underweight may pose certain health risks, including nutrient deficiencies and hormonal changes. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. A person should consult with their healthcare provider and consider making lifestyle changes through healthy eating and fitness to improve their health indicators.Being underweight can cause health problems. An underweight person is a person whose body weight is considered too low to be healthy /n TIPS: /n *eat more frequently /n *choose nutrient-rich foods /n *watch what you eat and drink /n *exercise /n *limit your vices (drinking,smoking,etc)"
823 halign: "left"
824
825 Widget:
826
827 MDScreen:
828 MDRectangleFlatButton:
829 mode: "rectangle"
830 text: 'Go to Main Menu'
831 pos_hint: {'center_x':0.5, 'center_y':0.8}
832 on_press : root.manager.current='menu'
833
834<LocationSearchScreen>
835 BoxLayout:
836 orientation: 'vertical'
837 MDToolbar:
838 title:'Hospital Searcher'
839 elevation:10
840 left_action_items:[["backspace",lambda x:app.back_screen6("menu")]]
841 right_action_items:[["head-question",lambda x:app.info1_dialog()]]
842
843 ScrollView:
844 MDList:
845 id: rlist
846<RecordLine>:
847 adaptive_height: True
848 OneLineListItem:
849 text: root.text
850 on_release: app.showinfo(root.parent.parent.panel_cls.text, self.text)
851
852<InformationDialog>:
853 title: "Details:"
854
855<OneLineAvatarIconListItem>: # The list widget
856 id: icnlst
857 IconLeftWidget:
858 icon: "clipboard"
859 RightCheckbox:
860 id: cb
861 Container:
862 MDIconButton:
863 icon:'close-circle-outline'
864 on_release: app.remove_one_item(root.text)
865
866<HistoryScreen>
867 MDFloatingActionButton:
868 icon: "magnify"
869 md_bg_color: app.theme_cls.primary_color
870 pos_hint: {"center_x": .8, "center_y": .1}
871 user_font_size: "25sp"
872 on_release:
873 app.show_database()
874
875 MDTextField:
876 id: inp
877 hint_text: 'Enter Full Name'
878 size_hint_x: None
879 pos_hint: {"center_x": .4, "center_y": .1}
880 width: '170dp'
881
882 MDCard:
883 size_hint: None, None
884 size: "280dp", "280dp"
885 pos_hint: {"center_x": .5, "center_y": .5}
886 orientation: "vertical"
887
888 ScrollView:
889 MDList:
890 id: list
891
892 MDToolbar:
893 id: toolbar
894 pos_hint: {"top": 1}
895 elevation: 6
896 title: "Check History"
897 left_action_items:[["backspace",lambda x:app.back_screen("menu")]]