File tree Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change
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
+ 
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/)
Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ def createTable(data, city):
40
40
# Populate table with weather information for each new US city
41
41
def NewEntry (data , city ):
42
42
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 ))
46
46
weather = data ['list' ][2 ]['weather' ][0 ]['main' ]
47
47
weather_desc = data ['list' ][2 ]['weather' ][0 ]['description' ]
48
48
You can’t perform that action at this time.
0 commit comments