├── images_prev_ui.png └── index.py /images_prev_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamza-Rashed/COVID-19-Tkinter/HEAD/images_prev_ui.png -------------------------------------------------------------------------------- /index.py: -------------------------------------------------------------------------------- 1 | from tkinter import * ## for drowing a disktop application 2 | from tkinter.font import Font 3 | import matplotlib.pyplot as plt 4 | from PIL import ImageTk , Image 5 | 6 | class Window: # OOP 7 | 8 | """ 9 | This class for create a multibal windows with same props 10 | """ 11 | def __init__(self, root): 12 | self.root = root 13 | 14 | def welcomePage(self): 15 | """ 16 | This function for welcome page and contain The styles for the Items 17 | """ 18 | global FontWelcomeButton 19 | global FontWelcomeLable 20 | global FontMainButton 21 | FontWelcomeLable = Font( 22 | family="Times", 23 | size=42, 24 | weight="bold", 25 | slant="roman" 26 | ) 27 | FontWelcomeButton = Font( 28 | family="Times", 29 | size=30, 30 | weight="bold", 31 | slant="roman" 32 | ) 33 | FontMainButton = Font( 34 | family="Times", 35 | size=35, 36 | weight="bold", 37 | slant="roman" 38 | ) 39 | 40 | my_image = ImageTk.PhotoImage(Image.open('images_prev_ui.png')) # for Image in welcome page 41 | Label(self.root, image = my_image).pack(side = LEFT) 42 | 43 | Label(self.root, text="We are AL-Nkhba Team Preasnted \n to you a simple program for covid-19 \n around the world !!" , width = 100 , height = 7 , font = FontWelcomeLable , bg = '#f0f0f0').pack() 44 | Button(self.root, text="Next", command=self.mainPage , bg = 'blue' , width = 10 , height = 2 , font = FontWelcomeButton , fg = "white").pack() 45 | w, h = self.root.winfo_screenwidth(), self.root.winfo_screenheight() # for size the window on welcome page 46 | self.root.geometry("%dx%d+0+0" % (w, h)) 47 | self.root.configure(background = '#f0f0f0') # for background 48 | self.root.mainloop() # for turn on the function 49 | 50 | def mainPage(self): 51 | """ 52 | This Function For main page which contain on all Mains Buttons 53 | """ 54 | global rootMain 55 | rootMain = Tk() 56 | Button(rootMain, text="Number Of Injuries" , command = self.numberOfInjuries , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 57 | Button(rootMain, text="Number Of Recovery" , command = self.numberOfRecovery , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT) 58 | Button(rootMain, text="Number Of Deaths" , command = self.numberOfDeaths , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 59 | Button(rootMain, text="Number Of Fortified" , command = self.numberOfFortified , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT) 60 | rootMain.title("Main Page") 61 | w, h = rootMain.winfo_screenwidth(), rootMain.winfo_screenheight() 62 | rootMain.geometry("%dx%d+0+0" % (w, h)) 63 | rootMain.configure(background = '#f0f0f0') 64 | rootMain.mainloop() 65 | 66 | def numberOfInjuries(self): 67 | rootMain.destroy() 68 | global rootInjuries 69 | rootInjuries = Tk() 70 | Label(rootInjuries, text="The number of cases of Covid-19 around the world!!" , width = 100 , height = 7 , font = FontWelcomeLable , bg = '#f0f0f0').pack() 71 | 72 | def graphs(): 73 | labels = 'World population', 'Percentage of injured' 74 | sizes = [7800000000, 144250358] 75 | colors = ['blue', 'red'] 76 | explode = (0, 0) 77 | 78 | plt.pie(sizes, explode=explode, labels=labels, colors=colors, 79 | autopct='%1.1f%%', shadow=True) 80 | 81 | plt.axis('equal') 82 | plt.show() 83 | 84 | def graphsDate(): 85 | months = ['3/2020', '4/2020', '5/2020', '6/2020', '7/2020', '8/2020', 86 | '9/2020', '10/2020', '11/2020', '12/2020', '1/2021', '2/2021', '3/2021', '4/2021'] 87 | Numbers = [89000, 140000, 158000, 180000, 290000, 295000, 88 | 322000, 551000, 595000, 760000, 530000, 400000, 650000, 832000] 89 | plt.plot(months, Numbers, linestyle='dashed', color='blue') 90 | plt.xticks(months, months) 91 | plt.ylabel('The number of injured') 92 | plt.xlabel('Months') 93 | plt.show() 94 | 95 | Button(rootInjuries, text="Percentage of the number \n of injured", command=graphs , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 96 | Button(rootInjuries, text="The rate of increase in injuries \n with dates", 97 | command=graphsDate , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT) 98 | Button(rootInjuries, text="Back To Main Page" , command = self.mainPage , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 99 | rootInjuries.title("Cases of injuries") 100 | w, h = rootInjuries.winfo_screenwidth(), rootInjuries.winfo_screenheight() 101 | rootInjuries.geometry("%dx%d+0+0" % (w, h)) 102 | rootInjuries.configure(background = '#f0f0f0') 103 | rootInjuries.mainloop() 104 | 105 | def numberOfRecovery(self): 106 | rootMain.destroy() 107 | global rootRecovery 108 | rootRecovery = Tk() 109 | Label(rootRecovery, text="Cases that have recovered from Covid 19 around the world!!" , width = 100 , height = 7 , font = FontWelcomeLable , bg = '#f0f0f0').pack() 110 | 111 | def graphs(): 112 | labels = 'Percentage of Recovered', 'Percentage of injured' 113 | sizes = [122712466, 144250358] 114 | colors = ['blue', 'red'] 115 | explode = (0.1, 0) 116 | 117 | plt.pie(sizes, explode=explode, labels=labels, colors=colors, 118 | autopct='%1.1f%%', shadow=True) 119 | 120 | plt.axis('equal') 121 | plt.show() 122 | 123 | def graphsDate(): 124 | months = ['3/2020', '4/2020', '5/2020', '6/2020', '7/2020', '8/2020', 125 | '9/2020', '10/2020', '11/2020', '12/2020', '1/2021', '2/2021', '3/2021', '4/2021'] 126 | Numbers = [49000, 135000, 136000, 120360, 245000, 222500, 127 | 318000, 535000, 580000, 756000, 580000, 367000, 590000, 750600] 128 | plt.plot(months, Numbers, linestyle='dashed', color='blue') 129 | plt.xticks(months, months) 130 | plt.ylabel('The number of Recovered') 131 | plt.xlabel('Months') 132 | plt.show() 133 | 134 | Button(rootRecovery, text="Percentage of the number \n of recovered", command=graphs , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 135 | Button(rootRecovery, text="The rate of increase in recovered \n with dates", 136 | command=graphsDate , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 137 | Button(rootRecovery, text="Back To Main Page" , command = self.mainPage , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton, fg = "white").pack(side = LEFT , padx = 50) 138 | rootRecovery.title("Cases of Recovered") 139 | w, h = rootRecovery.winfo_screenwidth(), rootRecovery.winfo_screenheight() 140 | rootRecovery.geometry("%dx%d+0+0" % (w, h)) 141 | rootRecovery.configure(background = '#f0f0f0') 142 | rootRecovery.mainloop() 143 | 144 | def numberOfDeaths(self): 145 | rootMain.destroy() 146 | global rootDeaths 147 | rootDeaths = Tk() 148 | Label(rootDeaths, text="The number of Deaths Because of Covid-19 around the world" , width = 100 , height = 7 , font = FontWelcomeLable , bg = '#f0f0f0').pack() 149 | 150 | def graphs(): 151 | labels = 'Percentage of Deaths', 'Percentage of injured' 152 | sizes = [3073896, 144250358] 153 | colors = ['blue', 'red'] 154 | explode = (0.1, 0) 155 | 156 | plt.pie(sizes, explode=explode, labels=labels, colors=colors, 157 | autopct='%1.1f%%', shadow=True) 158 | 159 | plt.axis('equal') 160 | plt.show() 161 | 162 | def graphsDate(): 163 | months = ['3/2020', '4/2020', '5/2020', '6/2020', '7/2020', '8/2020', 164 | '9/2020', '10/2020', '11/2020', '12/2020', '1/2021', '2/2021', '3/2021', '4/2021'] 165 | Numbers = [4300, 7200, 4400, 5310, 6507, 4200, 166 | 5700, 6710, 7820, 14100, 17100, 6300, 12000, 14125] 167 | plt.plot(months, Numbers, linestyle='dashed', color='blue') 168 | plt.xticks(months, months) 169 | plt.ylabel('The number of Recovered') 170 | plt.xlabel('Months') 171 | plt.show() 172 | 173 | Button(rootDeaths, text="Percentage of the number \n of Deaths", command=graphs , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 174 | Button(rootDeaths, text="The rate of increase in Deaths \n with dates", 175 | command=graphsDate , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 176 | Button(rootDeaths, text="Back To Main Page" , command = self.mainPage , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 177 | rootDeaths.title("Cases of Deaths") 178 | w, h = rootDeaths.winfo_screenwidth(), rootDeaths.winfo_screenheight() 179 | rootDeaths.geometry("%dx%d+0+0" % (w, h)) 180 | rootDeaths.configure(background = '#f0f0f0') 181 | rootDeaths.mainloop() 182 | 183 | def numberOfFortified(self): 184 | rootMain.destroy() 185 | global rootFortified 186 | rootFortified = Tk() 187 | Label(rootFortified, text="Cases that have Fortified from Covid 19 around the world!!" , width = 100 , height = 7 , font = FontWelcomeLable , bg = '#f0f0f0').pack() 188 | 189 | def graphs(): 190 | labels = 'Percentage of Fortified', 'Percentage of injured' 191 | sizes = [217000000, 144250358] 192 | colors = ['blue', 'red'] 193 | explode = (0.1, 0) 194 | 195 | plt.pie(sizes, explode=explode, labels=labels, colors=colors, 196 | autopct='%1.1f%%', shadow=True) 197 | 198 | plt.axis('equal') 199 | plt.show() 200 | 201 | def graphsDate(): 202 | months = ['2/2021', '3/2021', '4/2021'] 203 | Numbers = [45600000, 65450000, 105950000] 204 | plt.plot(months, Numbers, linestyle='dashed', color='blue') 205 | plt.xticks(months, months) 206 | plt.ylabel('The number of Fortified') 207 | plt.xlabel('Months') 208 | plt.show() 209 | 210 | Button(rootFortified, text="Percentage of the number \n of Fortified", command=graphs , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 211 | Button(rootFortified, text="The rate of increase in Fortified \n with dates", 212 | command=graphsDate , bg = 'purple' , width = 30 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 213 | Button(rootFortified, text="Back To Main Page" , command = self.mainPage , bg = 'blue' , width = 22 , height = 5 , font = FontMainButton , fg = "white").pack(side = LEFT , padx = 50) 214 | rootFortified.title("Cases of Fortified") 215 | w, h = rootFortified.winfo_screenwidth(), rootFortified.winfo_screenheight() 216 | rootFortified.geometry("%dx%d+0+0" % (w, h)) 217 | rootFortified.configure(background = '#f0f0f0') 218 | rootFortified.mainloop() 219 | 220 | 221 | if __name__ == '__main__': # for turn on the welcome page 222 | root = Tk() 223 | mainRoot = Window(root) 224 | mainRoot.welcomePage() 225 | --------------------------------------------------------------------------------