A tool and framework to simplify construction of Python Dash applications.
Project description
dash-builder
[!IMPORTANT]
dash-builder
and its developer(s) are not associated with the originaldash
project or its commercial parent, Plotly.
A tool and framework to simplify construction of Python Dash applications.
API Design
- Create a project in the current working directory
> dash build
- Create project called
testproject
in specified directory
> dash build testproject --location ~/projects
- Add new page to current dash project in pages/ directory
> dash page NewPage
- Add new page to current dash project in specific directory within pages/
> dash page NewPage --location archive
Installation
pip install dash-builder
Usage
dash-builder
provides a simple command-line interface (CLI) for initiating and managing your dash
project.
Initiating a Dash Project
The create
command creates a new skeleton project.
It takes a single argument, the name for the new project.
You can use the --location
option to choose the directory in which to create it.
If no location
is passed, it will be created in the current working directory.
❯ dashb create test-project
3/3 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Complete
test-project successfully created in /Users/<username>.
📂 test-project
├── 📂 pages
│ ├── home.py
│ └── not_found_404.py
└── app.py
dash-builder
implements defines 2x classes to be used when building apps:
DashPage
- all page modules should define a page object that inherits from this abstract base class.DashView
- all page components should be constructed as views that inerhit from this abstract base class.
Framework
Under this framework:
- Applications are composed of pages using Dash's multi-page settings.
- Page modules define a page-object that subclasses the
DashPage
. - Page layouts are collections of views, created by subclassing the
DashView
. - Views define individual or collections of dash components, or other views.
- Views can be reused to create similar components.
- IDs are managed via the Views to simplify callback management.
- When re-using Views, pattern-matching callbacks can be useful to reduce the number of callbacks.
For example, the below:
- my-dash-project/
- pages/
- home.py
- views/
- __init__.py
- demo_input.py
- demo_output.py
- demo_view.py
- demo_view_2.py
- app.py
- pages/
# app.py
import dash
from dash import html
app = dash.Dash(__name__, use_pages=True)
app.layout = html.Div(
[
html.H1("Demo Application"),
html.Div(dash.page_container)
]
)
if __name__ == "__main__":
app.run(debug=True)
# pages/home.py
import dash
from dash import html, Input, Output
from dash_builder import DashPage
from views import DemoView, DemoView2, DemoInput, DemoOutput
dash.register_page(__name__, path="/")
class HomePage(DashPage):
@classmethod
def valid_layout(cls, **kwargs):
one = DemoView.create("one")
two = DemoView.create("two")
three = DemoView2.create("three")
return html.Div([one, two, three])
def layout(**kwargs):
return HomePage.layout(**kwargs)
@dash.callback(
Output(DemoOutput.matched_id(), "children"),
Input(DemoInput.matched_id(), "value")
)
def update_value(value: str) -> str:
return value
@dash.callback(
Output(DemoView2.id("three", "output"), "children"),
Input(DemoView2.id("three", "input"), "value")
)
def update_value_2(value: str) -> str:
return value
# views/demo_input.py
from dash import dcc
from dash_builder import DashView
class DemoInput(DashView):
@classmethod
def create(cls, id:str, **kwargs) -> dcc.Inupt:
return dcc.Input(id=cls.id(id))
# views/demo_output.py
from dash import html
from dash_builder import DashView
class DemoOutput(DashView):
@classmethod
def create(cls, id: str, **kwargs) -> html.Pre:
return html.Pre(id=cls.id(id))
# views/demo_view.py
from dash import html
from dash_builder import DashView
from . import DemoInput, DemoOutput
class DemoView(DashView):
@classmethod
def create(cls, id: str, **kwargs) -> html.Span:
input = DemoInput.create(id)
output = DemoOutput.create(id)
return html.Span([input, output], id=cls.id(id))
# views/demo_view_2.py
from dash import html, dcc
from dash_builder import DashView
class DemoView2(DashView):
@classmethod
def create(cls, id: str, **kwargs) -> html.Span:
input = dcc.Input(id=cls.id(id, "input"))
output = html.Pre(id=cls.id(id, "output"))
return html.Span([input, output], id=cls.id(id))
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
Built Distribution
File details
Details for the file dash_builder-0.1.5.tar.gz
.
File metadata
- Download URL: dash_builder-0.1.5.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2b56d091469cf8aee5a430643ad420dd76a9fe2172fd4e9a6ae831eeebc93b |
|
MD5 | da3102e361f7c480187fcd48bc1316b0 |
|
BLAKE2b-256 | c19799ee47e37cdc763206ad15f9f0b63b20ba9ee05fc4168d6038f1b5f6d88a |
Provenance
The following attestation bundles were made for dash_builder-0.1.5.tar.gz
:
Publisher:
publish-package.yaml
on robfs/dash-builder
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
dash_builder-0.1.5.tar.gz
- Subject digest:
cd2b56d091469cf8aee5a430643ad420dd76a9fe2172fd4e9a6ae831eeebc93b
- Sigstore transparency entry: 186280804
- Sigstore integration time:
- Permalink:
robfs/dash-builder@5d916858dfa836897886f220dbf952069f40c236
- Branch / Tag:
refs/heads/main
- Owner: https://github.com/robfs
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
publish-package.yaml@5d916858dfa836897886f220dbf952069f40c236
- Trigger Event:
workflow_dispatch
- Statement type:
File details
Details for the file dash_builder-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: dash_builder-0.1.5-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8401dd9a43cd4f48ae1c8fd676e1d499c49d4f53912070d3fb4445ea5e845c7 |
|
MD5 | c19be655b486e3cb764d71ededea2ffd |
|
BLAKE2b-256 | 988929559eab231a50ca7853371573aea1c74943c21c422d98e08a1c24507e1c |
Provenance
The following attestation bundles were made for dash_builder-0.1.5-py3-none-any.whl
:
Publisher:
publish-package.yaml
on robfs/dash-builder
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
dash_builder-0.1.5-py3-none-any.whl
- Subject digest:
d8401dd9a43cd4f48ae1c8fd676e1d499c49d4f53912070d3fb4445ea5e845c7
- Sigstore transparency entry: 186280810
- Sigstore integration time:
- Permalink:
robfs/dash-builder@5d916858dfa836897886f220dbf952069f40c236
- Branch / Tag:
refs/heads/main
- Owner: https://github.com/robfs
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
publish-package.yaml@5d916858dfa836897886f220dbf952069f40c236
- Trigger Event:
workflow_dispatch
- Statement type: