On Thursday, March 24, 2016 at 1:19:31 PM UTC-5, john lunzer wrote:
>
> Some random searching around the internet seems to indicate it should be 
> possible <https://github.com/jbaayen/ipython-notebook-browser>. Though 
> they used PySide.
>

Thanks for this.  The following also kinda works, when executed as a Leo 
script:

from leo.core.leoQt import QtCore, QtWebKit, QtWebKitWidgets, QtWidgets
from leo.plugins.free_layout import FreeLayoutController
from leo.plugins.nested_splitter import NestedSplitter

class JupyterWidget(QtWebKitWidgets.QWebView):

    def __init__(self):
        QtWebKitWidgets.QWebView.__init__(self)
        self.load(QtCore.QUrl(
            "http://localhost:8888/notebooks/export-neural-networds.ipynb";))
            
splitter = c.frame.top.splitter
    # The splitter containing the outline & log panes.
splitter.insert(1, w=JupyterWidget())

This does show the notebook, provided the Jupyter kernel is running and can 
access the .ipynb file). However, the page says "not connected". Some, but 
not all, of the page works as expected.

Furthermore, replacing the url above with the "main" url:
"http://localhost:8888/tree";
again does show the page, but it's not possible to load any of the visible 
.ipynb files.

There may be an extremely simple explanation for this. As you can see, the 
JupyterWidget class doesn't do anything except load a single url. It may be 
(probably is) necessary to connect events...

One more thing. The following code makes the JupyterWidget available to the 
Easter Egg interface:

class JupyterProvider:

    def ns_provider_id(self):
        return 'JupyterProvider'

    def ns_provides(self):
        return [('Jupyter', '_jupyter_widget_id')]

    def ns_provide(self, id_):
        if id_ == '_jupyter_widget_id':
            return JupyterWidget()
            
splitter.register_provider(JupyterProvider())

So clearly, it is possible to embed the widget, and I suspect it will be 
straightforward to make it fully functional.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to