einteract


Nameeinteract JSON
Version 1.4.2 PyPI version JSON
download
home_pagehttps://github.com/asaboor-gh/einteract
SummaryAn enhanced version of ipywidgets's interactive widgets.
upload_time2025-09-08 00:04:55
maintainerNone
docs_urlNone
authorAbdul Saboor
requires_python>=3.9
licenseMIT
keywords jupyter widgets ipython interact interactive
VCS
bugtrack_url
requirements dashlab numpy pandas matplotlib
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# einteract

> [!WARNING]
> This package has been deprecated and is no longer actively maintained. For improved interactive dashboards within Jupyter and to access future developments, we recommend migrating to [DashLab](https://github.com/asaboor-gh/dashlab).

[![](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://asaboor-gh.github.io/einteract-docs/notebooks/index.html?path=einteract.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/asaboor-gh/einteract/HEAD?urlpath=%2Fdoc%2Ftree%2Feinteract-demo.ipynb)
[![PyPI version](https://badge.fury.io/py/einteract.svg)](https://badge.fury.io/py/einteract)
[![Downloads](https://pepy.tech/badge/einteract)](https://pepy.tech/project/einteract)

An enhanced interactive widget that lets you observe any trait of widgets, observe multiple functions and build beautiful dashboards which can be turned into full screen. This is a wrapper library around interact functionality in [ipyslides](https://github.com/asaboor-gh/ipyslides) which also provides rich content representations. 

![](interact.png)

## Installation

You can install einteract using pip:

```bash
pip install einteract
```

Or if you prefer to install from source, clone the repository and in its top folder, run:

```bash
pip install -e .
```

## Interactive Playground
**✨ Try it in your browser ✨**
| Jupyter Lab  | Notebook | Binder |
|----|---|--- |
|  [![](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://asaboor-gh.github.io/einteract-docs/lab/index.html?path=einteract.ipynb)  |  [![](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://asaboor-gh.github.io/einteract-docs/notebooks/index.html?path=einteract.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/asaboor-gh/einteract/HEAD?urlpath=%2Fdoc%2Ftree%2Feinteract-demo.ipynb) |

## Features

- **InteractBase**: Create interactive dashboard applications with minimal code by extending the `InteractBase` class and defining methods with the `@callback` decorator.
- **Custom Widgets**: 
    - Included custom built widgets for enhanced interaction. 
    - Pass any DOMWidget as a parameter to `interact/interactive` functions unlike default `ipywidgets.interactive` behavior.
    - Observe any trait of the widget by `'widget_name.trait_name'` where `'widget_name'` is assigned to a `widget`/`fixed(widget)` in control parameters, OR `'.trait_name'` if `trait_name` exists on instance of interactive.
    - You can use '.fullscreen' to detect fullscreen change and do actions based on that.
    - Add `ipywidgets.Button` to hold callbacks which use it as paramter for a click
- **Plotly Integration**: Modified plotly support with additional traits like `selected` and `clicked`
- **HTML support**: 
   - Any (supported) python object can be converted to html using `hstack` and `vstack` function.
- **JupyTimer**: A non-blocking widget timer for Jupyter Notebooks without threading/asyncio.
- **Event Callbacks**: Easy widget event handling with the `@callback` decorator inside the subclass of `InteractBase` or multiple functions in `interact/interactive` functions.
- **Full Screen Mode**: Transform your dashboards into full-screen applications by added button.

## Usage Example

```python
import numpy as np
import matplotlib.pyplot as plt
import ipywidgets as ipw
import pandas as pd
import plotly.graph_objects as go
import einteract as ei

dash = ei.Dashboard(
    fig = ei.patched_plotly(go.FigureWidget()), 
    html = ipw.HTML('**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-main'], 
    center=['fig','out-click'], 
    pane_widths=[3,7,0],
)

dash
```
![einteract.gif](einteract.gif)

## Comprehensive Examples
- Check out the [einteract-demo.ipynb](einteract-demo.ipynb) which demonstates subclassing `InteractBase`, using custom widgets, and observing multiple functions through the `@callback` decorator.
- See [Bandstructure Visualizer](https://github.com/asaboor-gh/ipyvasp/blob/d181ba9a1789368c5d8bc1460be849c34dcbe341/ipyvasp/widgets.py#L642) and [KPath Builder](https://github.com/asaboor-gh/ipyvasp/blob/d181ba9a1789368c5d8bc1460be849c34dcbe341/ipyvasp/widgets.py#L935) as comprehensive dashboards.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asaboor-gh/einteract",
    "name": "einteract",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Jupyter, Widgets, IPython, interact, interactive",
    "author": "Abdul Saboor",
    "author_email": "asaboor.my@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/8f/b7/a7b3f777190d9a7236cfa1ae4aed6647201158b35c08efe5284bd4007d75/einteract-1.4.2.tar.gz",
    "platform": null,
    "description": "\r\n# einteract\r\n\r\n> [!WARNING]\r\n> This package has been deprecated and is no longer actively maintained. For improved interactive dashboards within Jupyter and to access future developments, we recommend migrating to [DashLab](https://github.com/asaboor-gh/dashlab).\r\n\r\n[![](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://asaboor-gh.github.io/einteract-docs/notebooks/index.html?path=einteract.ipynb)\r\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/asaboor-gh/einteract/HEAD?urlpath=%2Fdoc%2Ftree%2Feinteract-demo.ipynb)\r\n[![PyPI version](https://badge.fury.io/py/einteract.svg)](https://badge.fury.io/py/einteract)\r\n[![Downloads](https://pepy.tech/badge/einteract)](https://pepy.tech/project/einteract)\r\n\r\nAn enhanced interactive widget that lets you observe any trait of widgets, observe multiple functions and build beautiful dashboards which can be turned into full screen. This is a wrapper library around interact functionality in [ipyslides](https://github.com/asaboor-gh/ipyslides) which also provides rich content representations. \r\n\r\n![](interact.png)\r\n\r\n## Installation\r\n\r\nYou can install einteract using pip:\r\n\r\n```bash\r\npip install einteract\r\n```\r\n\r\nOr if you prefer to install from source, clone the repository and in its top folder, run:\r\n\r\n```bash\r\npip install -e .\r\n```\r\n\r\n## Interactive Playground\r\n**\u2728 Try it in your browser \u2728**\r\n| Jupyter Lab  | Notebook | Binder |\r\n|----|---|--- |\r\n|  [![](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://asaboor-gh.github.io/einteract-docs/lab/index.html?path=einteract.ipynb)  |  [![](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://asaboor-gh.github.io/einteract-docs/notebooks/index.html?path=einteract.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/asaboor-gh/einteract/HEAD?urlpath=%2Fdoc%2Ftree%2Feinteract-demo.ipynb) |\r\n\r\n## Features\r\n\r\n- **InteractBase**: Create interactive dashboard applications with minimal code by extending the `InteractBase` class and defining methods with the `@callback` decorator.\r\n- **Custom Widgets**: \r\n    - Included custom built widgets for enhanced interaction. \r\n    - Pass any DOMWidget as a parameter to `interact/interactive` functions unlike default `ipywidgets.interactive` behavior.\r\n    - Observe any trait of the widget by `'widget_name.trait_name'` where `'widget_name'` is assigned to a `widget`/`fixed(widget)` in control parameters, OR `'.trait_name'` if `trait_name` exists on instance of interactive.\r\n    - You can use '.fullscreen' to detect fullscreen change and do actions based on that.\r\n    - Add `ipywidgets.Button` to hold callbacks which use it as paramter for a click\r\n- **Plotly Integration**: Modified plotly support with additional traits like `selected` and `clicked`\r\n- **HTML support**: \r\n   - Any (supported) python object can be converted to html using `hstack` and `vstack` function.\r\n- **JupyTimer**: A non-blocking widget timer for Jupyter Notebooks without threading/asyncio.\r\n- **Event Callbacks**: Easy widget event handling with the `@callback` decorator inside the subclass of `InteractBase` or multiple functions in `interact/interactive` functions.\r\n- **Full Screen Mode**: Transform your dashboards into full-screen applications by added button.\r\n\r\n## Usage Example\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport ipywidgets as ipw\r\nimport pandas as pd\r\nimport plotly.graph_objects as go\r\nimport einteract as ei\r\n\r\ndash = ei.Dashboard(\r\n    fig = ei.patched_plotly(go.FigureWidget()), \r\n    html = ipw.HTML('**Select Box/Lesso on figure traces**'),\r\n    A = (1,10), omega = (0,20), phi = (0,10),\r\n    sdata = 'fig.selected', cdata = 'fig.clicked', fs = '.isfullscreen',\r\n)\r\n@dash.callback('out-click', throttle = 200) # limit click rate by 200 ms\r\ndef on_click(cdata,html):\r\n    display(pd.DataFrame(cdata or {}))\r\n\r\n@dash.callback('out-select')\r\ndef on_select(sdata, html):\r\n    plt.scatter(sdata.get('xs',[]),sdata.get('ys',[]))\r\n    plt.show()\r\n\r\n@dash.callback('out-fs')\r\ndef detect_fs(fig, fs):\r\n    print(\"isfullscreen = \",fs)\r\n    fig.layout.autosize = False # double trigger\r\n    fig.layout.autosize = True\r\n\r\n@dash.callback\r\ndef plot(fig:go.FigureWidget, A, omega,phi): # adding type hint allows auto-completion inside function\r\n    fig.data = []\r\n    x = np.linspace(0,10,100)\r\n    fig.add_trace(go.Scatter(x=x, y=A*np.sin(omega*x + phi), mode='lines+markers'))\r\n\r\ndash.set_css({\r\n    '.left-sidebar':{'background':'whitesmoke'},\r\n    ':fullscreen': {'height': '100vh'}}\r\n)\r\ndash.set_layout(\r\n    left_sidebar=['A','omega','phi','html','out-main'], \r\n    center=['fig','out-click'], \r\n    pane_widths=[3,7,0],\r\n)\r\n\r\ndash\r\n```\r\n![einteract.gif](einteract.gif)\r\n\r\n## Comprehensive Examples\r\n- Check out the [einteract-demo.ipynb](einteract-demo.ipynb) which demonstates subclassing `InteractBase`, using custom widgets, and observing multiple functions through the `@callback` decorator.\r\n- See [Bandstructure Visualizer](https://github.com/asaboor-gh/ipyvasp/blob/d181ba9a1789368c5d8bc1460be849c34dcbe341/ipyvasp/widgets.py#L642) and [KPath Builder](https://github.com/asaboor-gh/ipyvasp/blob/d181ba9a1789368c5d8bc1460be849c34dcbe341/ipyvasp/widgets.py#L935) as comprehensive dashboards.\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An enhanced version of ipywidgets's interactive widgets.",
    "version": "1.4.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/asaboor-gh/einteract/issues",
        "Homepage": "https://github.com/asaboor-gh/einteract"
    },
    "split_keywords": [
        "jupyter",
        " widgets",
        " ipython",
        " interact",
        " interactive"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "facc17ecaeee2fa50c02e3c670955e5601cc3d82646d973b54ffc4de609f50f2",
                "md5": "fe9f21a1c934271f7098dd9a56152f33",
                "sha256": "80530f223937d4fe584a40bbcb18e39232c92a3b389888cc37fedc0572928d05"
            },
            "downloads": -1,
            "filename": "einteract-1.4.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe9f21a1c934271f7098dd9a56152f33",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9",
            "size": 5279,
            "upload_time": "2025-09-08T00:04:54",
            "upload_time_iso_8601": "2025-09-08T00:04:54.293208Z",
            "url": "https://files.pythonhosted.org/packages/fa/cc/17ecaeee2fa50c02e3c670955e5601cc3d82646d973b54ffc4de609f50f2/einteract-1.4.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8fb7a7b3f777190d9a7236cfa1ae4aed6647201158b35c08efe5284bd4007d75",
                "md5": "39e7dc6f5b46e7f1505daadbd819549c",
                "sha256": "f07e6a5d386c640f44c9eea2f30091ddb3c3b2602eaf4d41e914928afcf1ac6e"
            },
            "downloads": -1,
            "filename": "einteract-1.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "39e7dc6f5b46e7f1505daadbd819549c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6084,
            "upload_time": "2025-09-08T00:04:55",
            "upload_time_iso_8601": "2025-09-08T00:04:55.567790Z",
            "url": "https://files.pythonhosted.org/packages/8f/b7/a7b3f777190d9a7236cfa1ae4aed6647201158b35c08efe5284bd4007d75/einteract-1.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 00:04:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "asaboor-gh",
    "github_project": "einteract",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "dashlab",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        }
    ],
    "lcname": "einteract"
}
        
Elapsed time: 1.33620s