Weather with Python, TkInter, Raspberry Pi…
Just messing around this weekend with some Python and TkInter. I put together a little weather app which uses Weather Underground’s API to grab the current local weather conditions (or the weather conditions from the state and city specified in the script) and creates a window to display the weather using TkInter widgets.
The script is available on GitHub. You will need a Weather Underground API Key which you can get for free. The free key allows 500 free API calls per day.
The following information about the current weather conditions is displayed: observation location, observation time, weather conditions (clear, cloudy, etc), a visible representation (icon) of the current conditions, temperature in Fahrenheit, and relative humidity. Here is what my weather app looks like running on the Raspberry Pi.
Took me a bit to make the icon image to display correctly. The code snippet Display an Image from a URL (Tkinter, Python) helped me get it working.
I was messing on the Raspberry Pi, but I was able to get it to work with Python on Windows as well.
Weather Underground’s API has a lot more information. Things like wind direction and speed, amount of participation, visibility, and a bunch more. Would be pretty easy to expand this out display more.
Just a fun little project to learn something new on a Saturday evening. In case you missed earlier the Python code for my Weather app is on GitHub if you want to have a look.
Enjoy!
Introducing Python |
Python Cookbook |