How to use the jupyter-innotater.jupyter_innotater.mixins.DataChangeNotifierMixin function in jupyter-innotater

To help you get started, we’ve selected a few jupyter-innotater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ideonate / jupyter-innotater / jupyter-innotater / jupyter_innotater / uiinnotations.py View on Github external
__all__ = ['ButtonInnotation']

from ipywidgets import Button

from .data import Innotation
from .mixins import DataChangeNotifierMixin


class ButtonInnotation(Innotation, DataChangeNotifierMixin):
    """
    Allow embedding of an arbitrary widget object, e.g. for text display
    Must still have a data attribute of correct len, even if dummy values
    """

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.on_click_hook = kwargs.get('on_click', None)
        self.uindex = None

    def _create_widget(self):
        btn = Button(description=self.desc, disabled=self.disabled, layout=self.layout)
        if self.on_click_hook:
            btn.on_click(lambda b: self.call_on_click_hook(b))
        return btn
github ideonate / jupyter-innotater / jupyter-innotater / jupyter_innotater / innotaterwidget.py View on Github external
def _observe_targets(self, targets):
        for dw in targets:
            dw.widget_observe(self.update_data, names='value')
            if isinstance(dw, ChildrenChangeNotifierMixin):
                dw.on_children_changed(self.new_children_handler)
            if isinstance(dw, DataChangeNotifierMixin):
                dw.on_data_changed(self.updated_data_handler)