# Cell 1
from IPython.kernel.comm import Comm
def handle_comm_message(message): print(message)
comm = Comm('comm-target-name')comm.on_msg(handle_comm_message)
// Cell 2
%%javascript
var IPython = window.IPython IPython.notebook.kernel.comm_manager.register_target('comm-target-name', function(comm, data) {
comm.on_msg(function(msg) { console.log(msg) });
comm.send({'data': 'sent from the client'})
});
# Cell 3
comm.send(data={'data': 'sent from python'})Try switching your cell one and two.
(Sorry, on phone so can't test)
Thanks,
Jason
I've uploaded the notebook here for convenience. http://nbviewer.jupyter.org/gist/finaiized/ad8836b64a874518d32c40e7a4a03966
--
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 jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/f2c16cc5-b8bf-4ae4-9084-adab48d1dbce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.