Weather application with Open Weather API using Python and Tkinter
In this video, you will learn about how to create a GUI Weather App in Python. It uses Open Weather Map API to fetch the latest weather information of cities and
places around the globe. Also, we will be implementing the weather app with GUI (Graphical User Interface) rather than the traditional boring ways, which are widely
available, showing output in CLI(Command Line Interface).
Steps involved:-
1. Install and Import Modules
2. Initialize the Tkinter Window
3. Code the GUI (frontend elements)
4. Get OpenWeatherMap API
5. Create Weather Function
6. Call function using "Command" keyword.
We use the Label method to generate a label of text to indicate the purpose of the input field for city name.
Entry method is used to make an entry field for input of city name, to check its weather.
The textvaraible widget is used to store the inputted value, in the variable named: city_value
Other than these widgets we have also applied some styling to our code, by font size, color, etc.
city_name= Label(root, text = 'Enter City Name', font = 'Arial 12 bold').pack(pady=10) -to generate label heading
city = Entry(root, textvariable = city_value, width = 24, font='Arial 14 bold').pack() -entry field
We code a Check Weather Button, on which we click to check the weather of the user inputted city:
We give our button some styling, along with the name – ‘Check Weather’. We use the ‘command‘ widget, which shows what function (here, showWeather function)
would run on the click (key press) of the button, as coded in the previous step.
btn = Button(root, command = showWeather, text = "Check Weather", font="Arial 10", bg='lightblue', fg='black', activebackground="teal", padx=5, pady=5 ).pack(pady= 20)
After adding this, we add the output elements in our code. The elements on which our Weather information would be displayed.
Yet again, we add a label to title our result in the following text box
To display the output we use a text field, which gets its value, every time the “Check Weather” button is pressed. This envokes the function to check weather info
fetched from the API after processing, [output from the showWeather function]
weather_now = Label(root, text = "The Weather is: ", font = 'arial 12 bold').pack(pady=10)
tfield = Text(root, width=46, height=10)
tfield.pack()
Download the Source Code for Driver Drowsiness Detection in Python
Please download the source code for the Project using the link: https://github.com/Akkmr111/Weather-a...
The requirement for this Python project is pygame module which can be installed using command:
1. Requests – pip install requests
Conclusion:
That’s it for the tutorial. Hope you have learned well how to make a Weather App in Python and that too with a level up by coding an Interface Based script along with
API call (Open Weather Map) and Tkinter.
_______________________________________________________________________________________________________________________________________________________________
Other Python Projects:
GUI Based Scientific Calculator:- • Scientific GUI Calculator using Tkinter in...
Face Detection using Python:- • Real time Face detection project using Pyt...
GUI Based Music player:- • Learn How to Create an MP3 Music Player in...
GUI Based YouTube Video Downloader:- • Видео
GUI Based Digital clock:- • Create a digital clock using Tkinter | Tki...
GUI Based Text Editor:- • Build a basic Text Editor using Tkinter in...
Virtual Assistant:- • Build Iron Man Jarvis AI Desktop Voice Ass...
QR Code Generator and Reader:- • Python Project QR Code Generator with Sour...
web scraping weather data python | weather forecasting project in python | weather forecast project in python | weather app python | Open Weather API | weather | weather update today | weather project
________________________________________________________________________________________________________________________________________________________________
Connect with me:
Facebook:- / ak.kmr
Instagram:- / ak.kmr111
Email:- [email protected]
_______________________________________________________________________________________________________________________________________________________________
Subscribe:- / @project_guru
#python #weatherupdate #projectguru #viral #trending #recentlyupload #recommendation #tkinter #weather #weatherupdate #weatherprediction
Информация по комментариям в разработке