latitud, longitud = obtener_coordenadas(ciudad)
if latitud is None or longitud is None:
messagebox.showerror("Error", "No se encontraron coordenadas para esta ciudad")
return
url_clima = f"https://api.open-meteo.com/v1/forecast?latitude={latitud}&longitude={longitud}¤t_weather=true"
try:
with urllib.request.urlopen(url_clima) as respuesta:
datos = json.loads(respuesta.read().decode())
if "current_weather" in datos:
clima = datos["current_weather"]
temperatura = clima["temperature"]
viento = clima["windspeed"]
resultado.config(text=f" 📍: {ciudad}\n🌡: {temperatura}°C\n🌬 : {viento} km/h")
else:
messagebox.showerror("Error", "No se encontraron datos climáticos")
except Exception:
messagebox.showerror("Error", "No se pudo obtener el clima")
Configuración de la interfaz gráfica
Ready.
Reviews
Inspect
Bored Tan Scramble Suit
Controls
Properties
Availability & Pricing
| Distributor | Qty 1 | |
|---|---|---|
Assets
Welcome 👋
Flux helps you build PCBs faster with an AI teammate!
Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.