Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import wget
- import os.path
- import tkinter
- import matplotlib.pyplot as plt
- def dothis(orszag):
- global adatok
- URL = 'https://pomber.github.io/covid19/timeseries.json'
- if not os.path.exists('timeseries.json'):
- wget.download(URL, 'C:\\Users\\Svab\\PycharmProjects\\covid\\timeseries.json')
- else:
- os.remove('timeseries.json')
- wget.download(URL, 'C:\\Users\\Svab\\PycharmProjects\\covid\\timeseries.json')
- with open('timeseries.json') as f:
- data = json.load(f)
- hun = data[orszag]
- data.keys()
- adatok = []
- for i in hun:
- adatok.append([i['date'], i['confirmed'], i['deaths'], i['recovered']])
- for j in range(len(adatok)):
- adatok[j].append(adatok[j][1] - adatok[j][2] - adatok[j][3])
- def readcountries():
- global countries
- countries = []
- with open('counties.txt') as f:
- for c in f:
- countries.append(c.split('\n'))
- for shit in range(len(countries)):
- countries[shit].remove(countries[shit][1])
- def mutat():
- global adatok
- global lb
- screen = tkinter.Tk()
- screen.geometry('1280x768')
- country = lb.get(tkinter.ACTIVE)
- screen.title('\'{}\' Adatai'.format(country))
- dothis(country)
- vbar = tkinter.Scrollbar(screen)
- vbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
- text = tkinter.Text(screen, wrap=tkinter.WORD, yscrollcommand=vbar.set, height=700, width=200)
- text.pack()
- vbar.config(command=text.yview)
- #'{}'.format(adatok[i][0])
- text.insert(tkinter.END, 'Dátum{}'.format(15*' '))
- text.insert(tkinter.END, 'Megerősített fertőzött{}'.format(15*' '))
- text.insert(tkinter.END, 'Halálok száma{}'.format(15*' '))
- text.insert(tkinter.END, 'Meggyógyult{}'.format(20*' '))
- text.insert(tkinter.END, 'Aktív eset\n')
- for i in range(len(adatok)):
- text.insert(tkinter.END, '{}{}'.format((adatok[i][0]), 25*' '))
- text.insert(tkinter.END, '{}{}'.format((adatok[i][1]), 25*' '))
- text.insert(tkinter.END, '{}{}'.format((adatok[i][2]), 25*' '))
- text.insert(tkinter.END, '{}{}'.format((adatok[i][3]), 28*' '))
- text.insert(tkinter.END, '{}\n'.format(adatok[i][4]))
- x_tengely = []
- y_esetek = []
- y_halalok = []
- y_gyogyultak = []
- y_aktiv = []
- for xt in range(len(adatok)):
- x_tengely.append(adatok[xt][0][5:])
- for y1 in range(len(adatok)):
- y_esetek.append(adatok[y1][1])
- for y2 in range(len(adatok)):
- y_halalok.append(adatok[y2][2])
- for y3 in range(len(adatok)):
- y_gyogyultak.append(adatok[y3][3])
- for y4 in range(len(adatok)):
- y_aktiv.append(adatok[y4][4])
- plt.plot(x_tengely, y_esetek, label='Megerositett esetek')
- plt.plot(x_tengely, y_aktiv, label='Aktív esetek')
- plt.plot(x_tengely, y_gyogyultak, label='Meggyógyultak')
- plt.plot(x_tengely, y_halalok, label='Halálok')
- plt.xlabel('Dátum')
- plt.ylabel('Szám')
- plt.title('\'{}\' statisztikai gráfja'.format(country))
- plt.legend()
- plt.show()
- def window():
- global countries
- global lb
- screen = tkinter.Tk()
- screen.geometry('300x540')
- screen.title('COVID19')
- tkinter.Label(screen, text='Orszagok').pack()
- scroll = tkinter.Scrollbar(screen)
- scroll.pack(side=tkinter.RIGHT, fill=tkinter.Y)
- lb = tkinter.Listbox(screen, height=30, width=50, bd=3)
- lb.pack(fill=tkinter.Y)
- for item in countries:
- lb.insert(tkinter.END, item[0])
- lb.config(yscrollcommand=scroll.set)
- scroll.config(command=lb.yview)
- bt = tkinter.Button(screen, text='Mutat', command=mutat)
- bt.pack()
- screen.mainloop()
- readcountries()
- window()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement