Every time I click the button to get the weather (I used Json to get info from a website), the previous text remains and new text is printed under it, but I want the old text to be updated. How can I do that? Please help.
from tkinter import *
import requests
import json
root = Tk()
root.title("Weather")
root.geometry("600x400")
def RealWeather():
try:
api_request = requests.get("http://api.openweathermap.org/data/2.5/weather?appid=c2fc19de6fcd6869c4a9e167ee0f2eb7&q=" + city.get())
api = json.loads(api_request.content)
location = api['name'] + ", " + api['sys']['country']
temp = int(api['main']['temp'] - 273.15)
ws = api['wind']['speed']
status = api['weather'][0]['main']
Labelloc = Label(root, text="Location",background='#5182cf').grid(row=2,column=0)
Label_loc = Label(root, text=location ,background='#5182cf').grid(row=2, column=1)
Labeltemp = Label(root, text="Temperature",background='#5182cf').grid(row=3,column=0)
Label_temp = Label(root, text=temp,background='#5182cf').grid(row=3,column=1)
Labelws = Label(root, text="Wind Speed",background='#5182cf').grid(row=4,column=0)
Label_ws = Label(root, text=ws,background='#5182cf').grid(row=4,column=1)
Labelstatus = Label(root, text="Status",background='#5182cf').grid(row=5,column=0)
Label_status = Label(root, text=status,background='#5182cf').grid(row=5,column=1)
except Exception as e:
api = "Error..."
EmptyLabel = Label(root, text="", background='#5182cf').grid(row=1, column=0)
butn = Button(root, text="Search", command=RealWeather).grid(row=0, column=3)
Label1 = Label(root, text="Enter City: ").grid(row=0,column=0)
city = Entry(root)
city.grid(row=0, column=1, padx=20)
root.mainloop()