【发布时间】:2015-08-03 22:36:56
【问题描述】:
我在玩Brython。
我正在尝试弄清楚如何从 JavaScript 执行 Brython 代码。
http://www.brython.info/static_doc/en/jsobjects.html
对于我的具体情况,我正在监听 MIDI 事件(使用 https://github.com/cwilso/WebMIDIAPIShim)
我希望执行 Brython 代码以响应收到的 MIDI 事件。
目前我正在尝试:
function myMIDIMessagehandler( event )
{
if( brythonListener != null )
brythonListener( event );
和 Brython 代码:
<script type="text/python3">
from browser import document as doc, window, html
def foo(event):
print("BRYTHON!" + event);
window.brythonListener = foo
</script>
但是当我在我的 MIDI 键盘上按下一个音符时,我得到:
我不知道该怎么处理这个错误,而且我完全不确定这种方法是否合理。
【问题讨论】:
标签: javascript python-3.x brython