Skip to content

Commit 74c0b1f

Browse files
committed
Added a README and updated temperature conversion
Included a README file explaining how to use the application with images. In addition, I converted the weather temperature output from Kelvin to Fahrenheit.
1 parent d1f7481 commit 74c0b1f

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

tkinter_python_gui/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Tkinter Python GUI Example - US City Weather Forecaster
2+
3+
Tkinter is a Python module used to create cross-platform GUIs. USWeatherForecast.py demonstrates an example of a Tkinter application.
4+
5+
## How it works:
6+
1. Run the script `USWeatherForecast.py` by typing either:
7+
```bash
8+
python3 USWeatherForecast.py
9+
```
10+
or
11+
```bash
12+
python USWeatherForecast.py
13+
```
14+
2. A window will pop up that looks like the following screen:
15+
16+
![Windows 10 display of US Weather Forecaster application](./images/demo.png)
17+
18+
From this screen, enter in a US city name and click the "Get Weather" button.
19+
20+
3. The interface should update to display a table with the city's weather information.
21+
22+
![Windows 10 display of US Weather Forecaster with city entries](./images/demoData.png)
23+
24+
4. To add another city, enter a new city in the text box and click the "Add New City" button.
25+
26+
27+
## API Information
28+
The application displays the following information:
29+
30+
- The US city name entered by the user
31+
- The current temperature in Fahrenheit
32+
- The minimum daily temperature (Fahrenheit)
33+
- The maximum daily temperature (Fahrenheit)
34+
- The current weather condition
35+
- A brief description of the type of weather condition (more detail)
36+
37+
All of the above information is from the free, open-source [Open Weather Map RapidAPI](https://rapidapi.com/community/api/open-weather-map/)

tkinter_python_gui/USWeatherForecast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def createTable(data, city):
4040
# Populate table with weather information for each new US city
4141
def NewEntry(data, city):
4242
try:
43-
temp = data['list'][1]['main']['temp']
44-
temp_min = data['list'][1]['main']['temp_min']
45-
temp_max = data['list'][1]['main']['temp_max']
43+
temp = str(round((((int(data['list'][1]['main']['temp']) - 273.15) * 1.8) + 32), 2))
44+
temp_min = str(round((((int(data['list'][1]['main']['temp_min']) - 273.15) * 1.8) + 32), 2))
45+
temp_max = str(round((((int(data['list'][1]['main']['temp_max']) - 273.15) * 1.8) + 32), 2))
4646
weather = data['list'][2]['weather'][0]['main']
4747
weather_desc = data['list'][2]['weather'][0]['description']
4848

tkinter_python_gui/images/demo.png

6.78 KB
Loading
20.8 KB
Loading

0 commit comments

Comments
 (0)