EDIT: Google Group post
I'm playing with Brython.
I'm trying to figure out how to execute Brython code from JavaScript.
http://www.brython.info/static_doc/en/jsobjects.html <-- this looks like the relevant documentation page, but it seems to be lacking an example of invoking a Brython function from JavaScript.
For my specific situation, I am listening to MIDI events (using https://github.com/cwilso/WebMIDIAPIShim)
I want Brython code to execute in response to a MIDI event received.
Currently I'm trying:
function myMIDIMessagehandler( event )
{
if( brythonListener != null )
brythonListener( event );
and Brython code:
<script type="text/python3">
from browser import document as doc, window, html
def foo(event):
print("BRYTHON!" + event);
window.brythonListener = foo
</script>
But when I press a note on my midi keyboard, I get:
I don't know what to make of this error, and I'm not at all sure the approach is sound.