I am currently trying to create a weather app in Python using tkinter. I have programmed a button that gets input in the "city" variable. However when I press "search" on the button my "city" variable does not work and returns the name of the city for openweather API to search.
from tkinter import *
import tkinter as tk
from geopy.geocoders import Nominatim
from tkinter import ttk,messagebox
from timezonefinder import TimezoneFinder
from datetime import datetime
from meteostat import Point, Daily
import requests
import pytz
api_key = "secret_api_key"
root=Tk()
root.title("Weather App")
root.geometry("900x500+300+200")
root.resizable(False,False)
#entry box
entry1 = Entry(root, width = 20)
entry1.place(relx=0.5, rely=0.5, anchor=CENTER)
#CITY BUTTON
city = entry1.get()
#search button
btn = Button(root, text="search", command=city)
btn.place(x=450, rely=0.57, anchor=CENTER)
#Title text
label1 = Label(root,text="Welcome to the weather app", font=("Arial", 24))
label1.place(x=300, y=150)
#Enter a location text
label2 = Label(root,text="Enter your city", font=("Arial", 14))
label2.place(x=400, y=200)
#weather graphic
Search_image=PhotoImage(file="/Users/lucky/Downloads/cloudy (1).png")
myimage=Label(image=Search_image)
myimage.place(x=20,y=20)
weather_data = requests.get(
f"https://api.openweathermap.org/data/2.5/weather?q={city}&units=imperial&APPID={api_key}")
print(weather_data.json())
root.mainloop()