So, comms took me awhile to figure out, but it seems I have it working albeit a bit hacky. The extension I am working on is here: https://github.com/lgpage/nbtutor I would value any feedback or critique.
On Saturday, November 19, 2016 at 11:41:45 PM UTC+2, Logan Page wrote: > > comms is what I'm looking for thank you :) > > > On Saturday, November 19, 2016 at 4:14:50 PM UTC+2, takowl wrote: >> >> 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/d6e5bd9f-40b8-4a4e-a3af-20ed1c9036b6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
