├── demo ├── demo_gui.PNG └── demo_simple.PNG ├── README.md ├── Simple_Weather_Information.py └── GUI_Weather_Information.py /demo/demo_gui.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YasinRezvani/Real_Time_Weather_Information/HEAD/demo/demo_gui.PNG -------------------------------------------------------------------------------- /demo/demo_simple.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YasinRezvani/Real_Time_Weather_Information/HEAD/demo/demo_simple.PNG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Real_Time_Weather_Information 2 | The simple and with GUI weather app and I use [openweather](https://openweathermap.org/) API. 3 | # Install the requirements 4 | First you should install the requirements: 5 | ``` 6 | pip install requests beautifultable 7 | ``` 8 | # Demo 🎉 9 | ### Simple 10 | ![demo_simple](https://user-images.githubusercontent.com/77124662/132121423-a36db532-985a-4487-9170-aac8b9788897.PNG) 11 | ### GUI 12 | ![demo_gui](https://user-images.githubusercontent.com/77124662/132121425-7c689577-e460-4f42-8864-1260ce4f25c8.PNG) 13 | 14 | 15 | -------------------------------------------------------------------------------- /Simple_Weather_Information.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from beautifultable import BeautifulTable 3 | try: 4 | table = BeautifulTable() 5 | API_key = "9fed8863a2be30ce1cbecb13f6b57d0b" 6 | city = input("\nEnter the City: ") 7 | url = "http://api.openweathermap.org/data/2.5/weather?q="+city+"&appid="+API_key+"&lang = fa" 8 | data = requests.get(url).json() 9 | 10 | weather = data["weather"][0]["description"] 11 | wind_speed = str(data["wind"]["speed"]) + " m/s" 12 | temp = str(round(data["main"]["temp"] - 273.15)) + " °C" 13 | humidity = str(data["main"]["humidity"]) + " %" 14 | timezone = str(data["timezone"] / 3600) + " h" 15 | 16 | print("") 17 | table.columns.header = [city.title()] 18 | table.rows.append([weather]) 19 | table.rows.append([temp]) 20 | table.rows.append([humidity]) 21 | table.rows.append([timezone]) 22 | table.rows.append([wind_speed]) 23 | table.rows.header = ["Clouds:", "Temperature:", "Humidity:", "Time Zone:" , "Wind Speed:"] 24 | table.set_style(BeautifulTable.STYLE_BOX_ROUNDED) 25 | print(table) 26 | input() 27 | except: 28 | print("") 29 | print("-- City Not Found , Invalid Mode --") 30 | input() 31 | 32 | # Made By Yasin Rezvani 33 | -------------------------------------------------------------------------------- /GUI_Weather_Information.py: -------------------------------------------------------------------------------- 1 | from time import timezone 2 | import requests 3 | from tkinter import * 4 | from tkinter import ttk 5 | 6 | root= Tk() 7 | 8 | root.title("Real_Time_Weather_Information") 9 | root.geometry("500x290") 10 | root.resizable(False, False) 11 | 12 | label=Label(root, text="Enter the City: ", font=("Arial 18 bold")) 13 | label.pack() 14 | 15 | entry= Entry(root, width= 40) 16 | entry.pack() 17 | 18 | def get_data(): 19 | API_key = "9fed8863a2be30ce1cbecb13f6b57d0b" 20 | city = entry.get() 21 | url = "http://api.openweathermap.org/data/2.5/weather?q="+city+"&appid="+API_key+"&lang = fa" 22 | data = requests.get(url).json() 23 | weather = "Clouds: "+str(data["weather"][0]["description"]) 24 | wind_speed = "Wind Speed: "+str(data["wind"]["speed"]) + " m/s" 25 | temp = "Temperature: "+str(round(data["main"]["temp"] - 273.15)) + " °C" 26 | humidity = "Humidity: "+str(data["main"]["humidity"]) + " %" 27 | timezone = "Time Zone: "+str(data["timezone"] / 3600) + " h" 28 | 29 | weather_.configure(text=weather) 30 | wind_speed_.configure(text=wind_speed) 31 | temp_.configure(text=temp) 32 | humidity_.configure(text=humidity) 33 | timezone_.configure(text=timezone) 34 | 35 | 36 | ttk.Button(root, text= "Search",width= 20,command=get_data).pack(pady=10) 37 | lbl = Label(root, font=("Arial 15")) 38 | lbl.pack() 39 | weather_ = Label(root , font=("Arial 15") ,bg ="blue" , fg="white") 40 | weather_.pack() 41 | wind_speed_ = Label(root , font=("Arial 15") ,bg ="blue" , fg="white") 42 | wind_speed_.pack() 43 | temp_ = Label(root , font=("Arial 15") ,bg ="blue" , fg="white") 44 | temp_.pack() 45 | humidity_ = Label(root , font=("Arial 15") ,bg ="blue" , fg="white") 46 | humidity_.pack() 47 | timezone_ = Label(root , font=("Arial 15") ,bg ="blue" , fg="white") 48 | timezone_.pack() 49 | 50 | root.mainloop() 51 | 52 | --------------------------------------------------------------------------------