AgroSense / src /ui /tabs /weather_tab.py
RafaelJaime's picture
Open Meteo added
a187af6
"""
Weather Alerts Tab
==================
UI component for displaying agricultural weather alerts.
"""
import gradio as gr
from src.utils.weather_alerts import get_weather_alerts
def create_weather_tab():
"""Create the weather alerts tab."""
with gr.Tab("🌦️ Weather Alerts"):
gr.Markdown(
"""
Get real-time weather data and agricultural recommendations for your area.
Powered by [Open-Meteo](https://open-meteo.com/) - Free weather API.
"""
)
with gr.Row():
with gr.Column():
location_input = gr.Textbox(
label="πŸ“ Enter your location",
placeholder="e.g., Madrid, Spain or California, USA",
lines=1
)
weather_btn = gr.Button("πŸ” Get Weather Data", variant="primary")
gr.Markdown(
"""
**Tips:**
- Enter city name with country for best results
- Be specific: "Valencia, Spain" or "Iowa, USA"
- Includes 7-day forecast and agricultural recommendations
- Real-time data from Open-Meteo API
"""
)
with gr.Column():
weather_output = gr.Markdown(label="Weather Alerts")
# Connect button
weather_btn.click(
fn=get_weather_alerts,
inputs=[location_input],
outputs=[weather_output]
)