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