Sep-10-2021, 03:51 AM
(This post was last modified: Sep-10-2021, 10:10 AM by snippsat.
Edit Reason: Remove API key
)
Hello, I just started trying to learn programming 3 days ago. I'm following online courses and researching about 4-6 hours a day. I'm one of those who has to learn by doing and making mistakes so I started making an app that will log weather temps current, min/max each day as well as barometric pressure and humidity because I have Meniere's Disease and this affects it greatly. Would also help many others if they used it. I have just started and I don't know how to store the data as it comes in from the weather api and then record it in the app. Any help would be appreciated.
Thanks in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import tkinter as tk import requests import time def getWeather(): location = textfield.get() #https://api.openweathermap.org/data/2.5/weather?q=Winnsboro,Louisiana&appid=xxxxxxxxxxx api = "api.openweathermap.org/data/2.5/weather?q=" + city + state + "&appid=xxxxxxxxxxx" json_data = requests.get(api).json() condition = json_data[ 'weather' ][ 0 ][ 'main' ] temp = int (json_data[ 'main' ][ 'temp' ]) max_temp = int (json_data[ 'main' ][ 'temp_max' ]) min_temp = int (json_data[ 'main' ][ 'temp_min' ]) press = int (json_data[ 'main' ][ 'pressure' ]) #max_press = int(json_data['main']['pressure_max']) #min_press = int(json_data['main']['pressure_min']) humidity = int (json_data[ 'main' ][ 'humidity' ]) canvas = tk.Tk() canvas.geometry( "960x600" ) canvas.title( "Meniers App" ) f = ( "poppins" , 20 ,) t = ( "poppins" , 25 , "bold" ) textfield = tk.Entry(canvas, font = t) textfield.pack(pady = 25 ) textfield.focus() |
Larz60+ write Sep-10-2021, 08:55 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please don't use images to post code. Use bbcode instead.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please don't use images to post code. Use bbcode instead.
Fixed for you this time. Please use bbcode tags on future posts.