Package: dash-entrypoints
Dash entrypointsCLI & wrapper for multi-page apps, layout callbacks, and more.See features & entrypoints listed below.Entrypoint for multi-page appsPythonfromdash_entrypointsimportrun_entrypointkwargs={}run_entrypoint(**kwargs)Loadapp_datafrom file for use withrun_entrypoint(expectsdict, not a filepath)fromdash_entrypoints.miscimportload_app_datafromdash_entrypointsimportrun_entrypointapp_data_file="/some/file/path"app_data=load_app_data(file=app_data_file)run_entrypoint(app_data=app_data)CLIShow argumentsifentry--helpExample callifentry--app-nameTEST-NAME\--ip-address192.168.100.10\--views-module'mypackage.page_subpackage'\--assets-folder'/path/to/assets/folder'\--port9050\--debugElement wrappersSee for elements infrom interfaces_entrypoint import elementsStandard layouts fordash.DataTableWith column dropdownsfromdash_entrypoints.elements.table_with_dropdownimportadd_table_with_dropdown_columnskwargs={}table=add_table_with_dropdown_columns(**kwargs)With selection handlesfromdash_entrypoints.elements.table_for_selectionimportadd_table_for_selectionkwargs={}table=add_table_for_selection(**kwargs)With editable columns (& typecasting for entered edited values for homogenous data in callbacks)fromdash_entrypoints.elements.table_for_editingimportadd_table_with_editable_columnskwargs={}table=add_table_with_editable_columns(**kwargs)Popup (dbc.Modal) for information, e.g. as callback confirmationfromdash_entrypoints.elements.popup_for_informationimportadd_popup_for_informationpopup_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 objectsBox for buttons# TODO, see Issue #3Callback wrapper for inner layoutThis 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 examplesadd__example_callback_wrapper_dropdownandadd__example_callback_wrapper_selection)fromdash_entrypoints.elements.table_layout_wrapperimportwrap_part_layout_for_callbackPlugins for dashTo write a plugin, create a module .py file and add at least a methodplugto it.
Data can be assigned (& virtually treated like a global attribute of thedashmodule if assigned as attribute to it in theplugmethod).Writing plugins for Dash does not seem to be documented yet, but logic of plugins can be observed in some repos ongithub.com/plotlyor atdash_labs.plugins.pages.
See alsodash_entrypoints.pluginsfor examples.Example of mnimal pluginimportdashdefplug(app):# Assign data to `dash` moduledash.some_plugin_data_container={}# Plugin logic (Manipulate data here)# ...Example use of any pluginimportdashfromdash_entrypoints.pluginsimportminimalpluginapp=dash.Dash(plugins=[minimalplugin],)# Test here that `dash` already has the attribute from `minimalplugin`print(dash.minimal_plugin_attribute)# >> {'test1': 1}ContributingContributions are welcome! Please openissuesorpull requestsorget in touch.CitationRollik, 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--},}LicenseThis software is released under theBSD 3-Clause License