DashLab
An enhanced dashboarding library based on ipywidgets' interaction functionality that lets you observe any trait of widgets, observe multiple functions and build beautiful dashboards which can be turned into full screen.
Installation
You can install dashlab using pip:
pip install dashlab
Or if you prefer to install from source, clone the repository and in its top folder, run:
pip install -e .
Interactive Playground
✨ Try it in your browser ✨
| Jupyter Lab | Notebook | Binder |
|---|---|---|
Features
- DashboardBase: Create interactive dashboard applications with minimal code by extending the
dashlab.DashboardBaseclass and defining methods with the@callbackdecorator. - Dashboard: A ready-to-use dashboard class that allows quick setup of interactive dashboards without subclassing and supports callbacks after initialization.
- Custom Widgets:
- Included custom built widgets for enhanced interaction.
- Pass any DOMWidget as a parameter to
interact/interactivefunctions unlike defaultipywidgets.interactivebehavior. - Observe any trait of the widget by
'widget_name.trait_name'where'widget_name'is assigned to awidget/fixed(widget)in control parameters, OR'.trait_name'iftrait_nameexists on instance of interactive. - Tuple pattern (widget, 'trait') for trait observation where widget is accessible via params and trait value goes to callback.
This is useful to have widget and trait in a single parameter, such as
x = (fig, 'selected')for plotly FigureWidget. Other traits of same widget can be observed by separate parameters withy = 'x.trait'pattern. - You can use '.fullscreen' to detect fullscreen change and do actions based on that.
- Use
.paramsto acess widgets built with given parameters. - Use
varto observe any python variable which is not a widget and trigger callbacks whenvar.valuechanges. - Add
ipywidgets.Buttonto hold callbacks which use it as paramter for a click
- Plotly Integration: Modified plotly support with additional traits like
selectedandclicked - Markdown support:
- Convert markdown to HTML widget using
dashlab.markdownfunction. hstackandvstackfunctions support markdown strings to automatically convert to HTML and place in stack.
- Convert markdown to HTML widget using
- JupyTimer: A non-blocking widget timer for Jupyter Notebooks without threading/asyncio.
- Event Callbacks: Easy widget event handling with the
@callbackdecorator inside the subclass ofDashboardBaseor multiple functions ininteract/interactivefunctions. - Full Screen Mode: Transform your dashboards into full-screen applications by added button.
Usage Example
import numpy as np
import matplotlib.pyplot as plt
import ipywidgets as ipw
import pandas as pd
import plotly.graph_objects as go
import dashlab as dl
dash = dl.Dashboard(
fig = dl.patched_plotly(go.FigureWidget()),
html = dl.markdown('**Select Box/Lesso on figure traces**'),
A = (1,10), omega = (0,20), phi = (0,10),
sdata = 'fig.selected', cdata = 'fig.clicked', fs = '.isfullscreen',
)
@dash.callback('out-click', throttle = 200) # limit click rate by 200 ms
def on_click(cdata,html):
display(pd.DataFrame(cdata or {}))
@dash.callback('out-select')
def on_select(sdata, html):
plt.scatter(sdata.get('xs',[]),sdata.get('ys',[]))
plt.show()
@dash.callback('out-fs')
def detect_fs(fig, fs):
print("isfullscreen = ",fs)
fig.layout.autosize = False # double trigger
fig.layout.autosize = True
@dash.callback
def plot(fig:go.FigureWidget, A, omega,phi): # adding type hint allows auto-completion inside function
fig.data = []
x = np.linspace(0,10,100)
fig.add_trace(go.Scatter(x=x, y=A*np.sin(omega*x + phi), mode='lines+markers'))
dash.set_css({
'.left-sidebar':{'background':'whitesmoke'},
':fullscreen': {'height': '100vh'}}
)
dash.set_layout(
left_sidebar=['A','omega','phi','html', 'out-select','out-main'],
center=['fig','out-click'],
pane_widths=[3,7,0],
)
dash
Comprehensive Examples
- Check out the demo.ipynb which demonstates subclassing
DashboardBase, using custom widgets, and observing multiple functions through the@callbackdecorator. - See Bandstructure Visualizer and KPath Builder as comprehensive dashboards.
Metadata
Release files for dashlab 0.3.24
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dashlab-0.3.24.tar.gz | 54.1 kB | Without provenance | Details for dashlab-0.3.24.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dashlab-0.3.24-py3-none-any.whl | Python 3 | none | any | Details for dashlab-0.3.24-py3-none-any.whl |
Total release size: 111.2 kB
Release files / dashlab-0.3.24.tar.gz
| Download URL | dashlab-0.3.24.tar.gz |
|---|---|
| Size | 54.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2033943baa030864227364fdb8ad1a7124cc3fc064a9e8149465da2e5bedbaf1
|
|
BLAKE2b-256 checksum How to use checksums |
9cb6016ec2b0f0df8af72254409630f6dae6292e6557669ba49b386a1ecafd32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.18
|
Release files / dashlab-0.3.24-py3-none-any.whl
| Download URL | dashlab-0.3.24-py3-none-any.whl |
|---|---|
| Size | 57.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
919d9a1ff2c82c2e9266796f3090575d00c7519b38a9f3e594b98c778fa11b2f
|
|
BLAKE2b-256 checksum How to use checksums |
4f0ed970eb518cdd474c2fc9c923d32b0292e86b38e7ef27ac9744998028890b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.18
|
Security for dashlab 0.3.24
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.