On 18 November 2016 at 21:05, Logan Page <[email protected]> wrote:
> I have created some ipython cell magics (kernel extension) that populates
> a json object when a cell is executed.
> I need to get this json object into the front-end (javascript notebook
> extension) once complete.
>
> The hack I am using at the moment is simply to print the json str from
> ipython and use an "executed.CodeCell" event to wait for the output (print
> info).
One way you could do this is to have your notebook extension define a
Javascript callback function and make it globally accessible (which could
be by making it a handler for a new event you define, for instance). Then
you could wrap the JSON from the kernel in a call to that function and
display it as Javascript:
display(Javascript("my_callback_function(%s)" % json.dumps({'object from':
'kernel'})))
This would be called again whenever the notebook is loaded, though, as the
displayed Javascript is saved as an output.
A nicer solution involving a bit more work would be to use comms to send
your data:
http://jupyter-notebook.readthedocs.io/en/latest/comms.html
--
You received this message because you are subscribed to the Google Groups
"Project Jupyter" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jupyter/CAOvn4qjWGzgOioM%2B12BmrJr%2BWct0qETvdXHMdTwB-3y0QgdxPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.