I've been trying to figure out how to use comms to communicate from Python
<-> JS. Using the following simple example:
# 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'})
I can reliably get Python -> JS to work. In this case, after executing Cell
3, I receive the message in the console containing "Sent from Python" as
expected. However, I am unable to trigger the sending from client. I am not
sure if I have something set up incorrectly or I am simply misunderstanding
how comms work. Any help would be appreciated! Thanks!
--
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/527e3ff8-1549-4cf9-a98c-138ccff1e021%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.