Skip to main content

Dash entrypoints: Wrapper for dash/dash-labs multi-page app and specific layout elements.

Project description

DOI Website PyPI Wheel Code style: black pre-commit Contributions

Dash entrypoints

CLI & wrapper for multi-page apps, layout callbacks, and more.

See features & entrypoints listed below.

Entrypoint for multi-page apps

Python
from dash_entrypoints import run_entrypoint

kwargs = {}
run_entrypoint(**kwargs)
Load app_data from file for use with run_entrypoint (expects dict, not a filepath)
from dash_entrypoints.misc import load_app_data
from dash_entrypoints import run_entrypoint

app_data_file = "/some/file/path"
app_data = load_app_data(file=app_data_file)
run_entrypoint(app_data=app_data)
CLI

Show arguments

ifentry --help

Example call

ifentry --app-name TEST-NAME \
        --ip-address 192.168.100.10 \
        --views-module 'mypackage.page_subpackage' \
        --assets-folder '/path/to/assets/folder' \
        --port 9050 \
        --debug

Element wrappers

See for elements in from interfaces_entrypoint import elements

Standard layouts for dash.DataTable
With column dropdowns
from dash_entrypoints.elements.table_with_dropdown import add_table_with_dropdown_columns

kwargs = {}
table = add_table_with_dropdown_columns(**kwargs)
With selection handles
from dash_entrypoints.elements.table_for_selection import add_table_for_selection

kwargs = {}
table = add_table_for_selection(**kwargs)
With editable columns (& typecasting for entered edited values for homogenous data in callbacks)
from dash_entrypoints.elements.table_for_editing import add_table_with_editable_columns

kwargs = {}
table = add_table_with_editable_columns(**kwargs)
Popup (dbc.Modal) for information, e.g. as callback confirmation
from dash_entrypoints.elements.popup_for_information import add_popup_for_information

popup_list = [
        {
            "name": "success",
            "title": "Successfully inserted new entry.",
            "text": None,
            "close_button": False,
            "is_open": False,
        },
        {"name": "error", "title": "Error during insert", "close_button": True},
    ]
popup_layout, popup_list = add_popup_for_information(popup_list=popup_list)

# Add to main layout...
# Note: `popup_layout` is a list of popup layout objects
Box for buttons
# TODO, see Issue #3

Callback wrapper for inner layout

This tool helps to minimise boilerplate code while dynamically combining inner layout elements with a button in the outer layout that triggers a callback function that can be connected to the inner elements via (state, variable) tuples.

This function takes a part layout as list of dash layout elements, e.g. one or multiple tables, and a callback function plus the adequate states that feed data into the callback. The callback trigger is a button that gets added to the outer layout.

The outer callback wrapper only hands down the input data to the given callback function for processing. (See examples add__example_callback_wrapper_dropdown and add__example_callback_wrapper_selection)

from dash_entrypoints.elements.table_layout_wrapper import wrap_part_layout_for_callback

Plugins for dash

To write a plugin, create a module .py file and add at least a method plug to it. Data can be assigned (& virtually treated like a global attribute of the dash module if assigned as attribute to it in the plug method).

Writing plugins for Dash does not seem to be documented yet, but logic of plugins can be observed in some repos on github.com/plotly or at dash_labs.plugins.pages. See also dash_entrypoints.plugins for examples.

Example of mnimal plugin
import dash

def plug(app):
    # Assign data to `dash` module
    dash.some_plugin_data_container = {}

    # Plugin logic (Manipulate data here)
    # ...
Example use of any plugin
import dash
from dash_entrypoints.plugins import minimalplugin

app = dash.Dash(
    plugins=[minimalplugin],
)

# Test here that `dash` already has the attribute from `minimalplugin`
print(dash.minimal_plugin_attribute)
# >> {'test1': 1}

Contributing

Contributions are welcome! Please open issues or pull requests or get in touch.

Citation

Rollik, Lars B. (2022). Dash entrypoints: . doi: --DOI--.

BibTeX

@misc{rollik2021rpi,
    author       = {Lars B. Rollik},
    title        = {{Dash entrypoints: }},
    year         = {2022},
    month        = apr,
    publisher    = {Zenodo},
    url          = {https://doi.org/--DOI--},
    doi          = {--DOI--},
  }

License

This software is released under the BSD 3-Clause License

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

dash_entrypoints-0.2.3.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

dash_entrypoints-0.2.3-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file dash_entrypoints-0.2.3.tar.gz.

File metadata

  • Download URL: dash_entrypoints-0.2.3.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for dash_entrypoints-0.2.3.tar.gz
Algorithm Hash digest
SHA256 9fb02bb87769123f55509e52e5808962d1b82b76c0b4162f5588d9b810bfd029
MD5 c127a04af429715d054134bae47c07cd
BLAKE2b-256 d00a2f5c7d36711b52121f1875cceb817314ae1e102c7b78ab019fd96c33d1ec

See more details on using hashes here.

File details

Details for the file dash_entrypoints-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for dash_entrypoints-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 281b37864e9fdb17013a023a13661eb0ca499c1bfa073d5cc163a451b6b8eeb7
MD5 d100204727a7c57228d134a018ef7653
BLAKE2b-256 c225ad519f5a988ecdcbc2d3b998d5c7b5dddecfe9eb9bdc88557cc48c9a6e8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page