-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoro_api.py
More file actions
134 lines (97 loc) · 5.91 KB
/
Copy pathcoro_api.py
File metadata and controls
134 lines (97 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import requests
from bs4 import BeautifulSoup
from tkinter import *
from tkinter.font import Font
import time
import country_list
from tkinter import messagebox
class corona_update:
def __init__(self):
self.root = Tk()
self.root.resizable(False,False)
self.root.geometry('500x400+400+200')
self.country_name = 'india'
self.updates()
def updates(self):
self.root.title('CoroAPP - %s'%(self.country_name).title())
try:
self.main_frame = Frame(self.root, width = 500, height = 400,bg = 'midnight blue').place(x=0,y=0)
self.ref_b = Button(self.root,text= ' Refresh ', command = self.updates).place(x=35,y=375)
self.co = Entry(self.root, justify =CENTER)
#print(type(self.co))
self.co.place(x=267,y=377)
#print(type(self.co))
self.search = Button(self.root,text= ' Search ', command = self.coun).place(x=400,y=375)
self.fr_cfmd = Frame(self.root, width = 500, height = 125, bg = 'paleturquoise3', relief =RAISED, bd=4).place(x=0,y=0)
self.fr_succ = Frame(self.root, width = 250, height = 125, bg = 'pale green', relief =RAISED, bd=4).place(x=0,y=125)
self.fr_dang = Frame(self.root, width = 250, height = 125, bg = 'light coral', relief =RAISED, bd=4).place(x=250,y=125)
self.fr_info = Frame(self.root, width = 500, height = 125, bg = 'khaki1', relief =RAISED, bd=4).place(x=0,y=250)
self.ul = 'https://corona.help/country/%s'%(self.country_name)
self.page=requests.get(self.ul)
self.soup=BeautifulSoup(self.page.content,'html.parser')
self.confirmed_case = self.soup.find_all('h2',class_="text-bold-700 warning")
self.cfmd = str(self.confirmed_case).split('<')[1].split('>')[1]
self.cfmd1 = Label(self.fr_cfmd,
font=Font(family="Copperplate Gothic Light",size=25),
fg='blue4',bg='paleturquoise3',
text=' Total Confirmed Cases: ').place(x=20,y=10)
self.cfmd2 = Label(self.fr_cfmd,
font=Font(family="Copperplate Gothic Light",size=40),
fg='blue4',bg='paleturquoise3',
text=self.cfmd).place(x=120,y=50)
self.recoveries = self.soup.find_all('h2',class_="text-bold-700 success")
self.rcvr = str(self.recoveries).split('<')[1].split('>')[1]
self.rcvr1 = Label(self.fr_succ,
font=Font(family="Copperplate Gothic Light",size=14),
fg='blue4',bg='pale green',
text='Confirmed Recoveries:').place(x=4,y=129)
self.rcvr2 = Label(self.fr_succ,
font=Font(family="Copperplate Gothic Light",size=30),
fg='blue4',bg='pale green',
text=self.rcvr).place(x=60,y=170)
self.deaths = self.soup.find_all('h2',class_="text-bold-700 danger")
self.t_de = (str(self.deaths).split('<')[1].split('>')[1])
self.t_de1 = Label(self.fr_dang,
font=Font(family="Copperplate Gothic Light",size=18),
fg='blue4',bg='light coral',
text='Total Deaths:').place(x=280,y=129)
self.t_de2 = Label(self.fr_dang,
font=Font(family="Copperplate Gothic Light",size=30),
fg='blue4',bg='light coral',
text=self.t_de).place(x=300,y=170)
self.active_case = self.soup.find_all('h2',class_="text-bold-700 info")
self.accs = str(self.active_case).split('<')[1].split('>')[1]
self.accs1 = Label(self.fr_info,
font=Font(family="Copperplate Gothic Light",size=25),
fg='blue4',bg='khaki1',
text='Total Active Cases:').place(x=80,y=259)
self.accs2 = Label(self.fr_info,
font=Font(family="Copperplate Gothic Light",size=40),
fg='blue4',bg='khaki1',
text=self.accs).place(x=120,y=300)
ti = Label(self.main_frame, font=Font(family="Corbel",size=12),
fg='khaki1',bg='midnight blue',
text=time.strftime('%I:%M %p')).place(x=145,y=375)
except:
self.noCEF = Frame(self.root, width = 500, height = 400,bg = 'light coral').place(x=0,y=0)
self.noce1 = Label(self.noCEF, text='\n\n NO CONNECTION!!!!!',font=Font(family="Copperplate Gothic Light",size=30),
fg='red',bg='light coral').grid(row=1,column=1)
self.noce2 = Label(self.noCEF, text='\nConnect to Internet',font=Font(family="Copperplate Gothic Light",size=25),
fg='red',bg='light coral').grid(row=3,column=1)
self.ref_b = Button(self.root,text= ' Refresh ', command = self.updates).place(x=220,y=300)
def info(self):
self.ty =''' Please Enter Valid Country Name.
(E.g - United States >> united-states)'''
messagebox.showinfo('Input Error', self.ty)
def coun(self):
self.country_name = str(self.co.get())
self.country_name = self.country_name.lower()
if self.country_name in country_list.co_list:
self.co.delete(0,END)
self.updates()
else:
self.co.delete(0,END)
self.info()
obj=corona_update()
obj.root.iconbitmap('covid.ico')
obj.root.mainloop()