OpenWeather in Dash
Project description
openwid (OpenWeather in Dash) is a Python package for creating daily weather forecast components in Plotly Dash framework. You can easily add a fully responsive weather forecast card to your Dash applications. Before starting, you need to get a unique API key from OpenWeather website.
Install
openwid can be installed using
pip install openwid
Getting Started
Here is a very simple example that creates 7 day weather forecast card for Montréal:
import dash
import dash_bootstrap_components as dbc
import dash_html_components as html
from openwid import Openwid # Importing openwid
openwid_mon = Openwid(
api_key="YOUR_API_KEY", # <-- Edit Here
latitude="45.501690",
longitude="-73.567253"
)
app = dash.Dash(
__name__, meta_tags=[{"name": "viewport", "content": "width=device-width"}],
external_stylesheets = [dbc.themes.PULSE]
)
app.layout = html.Div(
[
html.Div(
[
dbc.Row(
dbc.Col(
openwid_mon.get_card(city_name="Montréal", days=7),
lg=6,
md=6,
sm=12
),
)
], style={"margin": "2rem"}
)
]
)
if __name__ == '__main__':
app.run_server(debug=True)
Constructor / reinitialise
OPENWID()
You can use Openwid class as an instance.
Openwid(
api_key="YOU_API_KEY",
latitude="LATITUDE",
longitude="LONGITUDE"
)
The Openwid()constructor takes the following arguments:
api_key
the unique OpenWeather API key
latitude
latitude of the location
longitude
longitude of the location
Component Functions
You can use this function to add a card component to your layout.
GET_CARD()
get_card(
city_name="CITY_NAME",
days=4,
bg_color="teal"
)
The get_cardfunction takes the following arguments:
city_name
the city name in card header
days
how many days weather forecast will be shown, default=4
bg_color
background color of the weather card, default=#00202f
Screenshots
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file openwid-0.1.3.tar.gz.
File metadata
- Download URL: openwid-0.1.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2277cc155e47f1807acda13b5fa7eea861f05329f8aefe6344ea537dff24afe
|
|
| MD5 |
c5ff1c63b2e1d333649e4988f5f45874
|
|
| BLAKE2b-256 |
74b16dc957c1d1fe9bfa62b97f0eb722eacffbca0d52b8338ab2705b3fc637de
|