A beautiful and responsive desktop Weather Application built with PyQt5, powered by the OpenWeatherMap API. Enter your city name to instantly get temperature, weather condition, and a corresponding emoji.
- Real-time weather info via OpenWeatherMap
- Temperature in Celsius
- Weather condition description
- Dynamic weather emojis (βοΈ π¦οΈ βοΈ etc.)
- Clear UI with Qt layouts and custom CSS styles
- Full error handling for various HTTP response codes.
- Python 3.x
- PyQt5
- Internet connection (to fetch API data)
- OpenWeatherMap API key
pip install pyqt5 requests
π§ͺ How to Run
Clone this repository or download the code.
Replace the default api_key in the script with your own OpenWeatherMap API key.
python
Copy
Edit
api_key = "YOUR_API_KEY_HERE"
Run the app:
bash
Copy
Edit
python weather_app.py
π API Information
This app uses OpenWeatherMap to fetch real-time weather data.
Endpoint used:
bash
Copy
Edit
https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}
π¨ UI & Layout
Built with QVBoxLayout for vertical stacking
Styled using Qt's setStyleSheet() for CSS-like customization
Dynamic emoji rendering using Unicode based on weather conditions
β οΈ Error Handling
The app gracefully handles:
City not found (404)
No internet connection
API authentication errors (401)
API rate limits and server errors
π‘ Emojis Mapping
Weather Code Range Emoji
200β232 (Thunder) π¦οΈ
300β321 (Drizzle) π§οΈ
500β531 (Rain) βοΈ
600β622 (Snow) βοΈ
701β762 (Mist etc.) βοΈ
800β804 (Clear/Clouds) βοΈ
Others π
π Project Structure
bash
Copy
Edit
weather-app/
βββ weather_app.py # Main application code
βββ README.md # You're reading this!