def myMIDIMessagehandler(event):statusByte, *data = event.data:def onSuccess( access )::window.navigator.requestMIDIAccess().then( onSuccess, onError ) // (1):print( "Ready!" )
Uncaught Error: Traceback (most recent call last):
module __main__ line 236
print( "Ready!" )
module __main__ line 85
statusByte, *data = event.data
NameError: 'data'
That seems to be suggesting that line 236 is only getting encountered when the event occurs.
It's a strange error, because it seems to be pointing in two different places at once, and both lines are legal Python (I've checked in Brython console).
My guess is that Brython has not implemented promises yet, and it is some kind of coincidence that this partially works rather than being entirely broken.
Could we hope for Promise support in Brython in the near future?
π
I guess so , because this will be the main building block necessary to
implement many other open tickets . It's just a matter of us having
time to get things done .
<head><script>function js_requestMIDIAccess( onSuccess, onError ) {window.navigator.requestMIDIAccess().then( onSuccess, onError );}</script><script src="/lib/bry_edge/brython.js"></script>
<script type="text/python3" src="./create.py"></script>
</head><body onload="console.log('a'); brython({debug:1, cache:'none'}); console.log('b');" >:
:def myMIDIMessagehandler(event):statusByte, *data_ = event.data:def onSuccess( access ):for v in access.inputs.values():v.onmidimessage = myMIDIMessagehandler:#window.navigator.requestMIDIAccess().then( onSuccess, onError )window.js_requestMIDIAccess( onSuccess, onError ):print( "Ready!" )