Eel: Unable to call function

Created on 4 Mar 2020  路  8Comments  路  Source: ChrisKnott/Eel

Describe the problem
I am not able to call python function from Javascript, i followed guides and it works on other program but not able to achieve it for this code.

Code snippet(s)
repo - https://github.com/axl3blaz3/Eel-help

@eel.expose
def start_record():
    ctypes.windll.user32.MessageBoxW(0, "ok", "Message", 1)
    eel.spawn(get_audio())

```javascript
var vClix = document.getElementById('canvas');
vClix.addEventListener('click',vRespondClick);

async function vRespondClick(){
var vText = document.getElementById('fire');

vText.innerHTML = 'Speak';
vText.style.color = '#ff3333';
vText.style.backgroundImage = 'linear-gradient('
        + 'to top' + ', ' + '#ff3333 0%' + ', ' + '#cc0000 100%' + ')';
vSpeed = 420;
vPhase = 35;
rangeMax = 10;
vClix.disabled = true;

console.log('start');   
await eel.start_record()(); 
console.log('end'); 
eel.expose(LisaTextract);
function LisaTextract(vLisaTexto){
    vLisaTextto();  
}

Desktop (please complete the following information):

  • OS: [Windows]
  • Browser [Chrome]
  • Version [ 80.0.3987.132]
help wanted

All 8 comments

I think the issue is the argument being passed is a function which can't be converted between languages.

there is no argument in await eel.start_record()();
and i it is not even running simple print message code;
python:
@eel.expose def start_record(): print('test')

I think @ChrisKnott means on the JavaScript side:

eel.expose(LisaTextract);
function LisaTextract(vLisaTexto){
    vLisaTextto();  
}

Yea i removed it for time being, but the Main problem in code is that the moment it hits the line with
await eel.start_record()(); the program is stuck there and it waits forever and does nothing.
Please test it on your local system and help me with the issue.
i think issue related to this :
def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument

I can't get your code running because can't find all the dependencies, but it is possibly an issue with using await at the top level and not within an async function. I am not 100% on JS's behaviour in this instance https://v8.dev/features/top-level-await

Is there a reason why this has to by synchronous? Can't you just change;
await eel.start_record()();
to
eel.start_record(); (one set of brackets)
?

I can change but for some reason it still isn't working for me...

Don't ask why, but If you change:
```

to

```
It all works fine.
I am not sure what async does inside script tag but somehow it was affecting how eel interacts. Never seen async used in such a way though.

You are a genius @RahulBadenkal TY so much <3 , you just saved a lot of trouble for me.
Thank YOOOUU, Mr.Rahul
Dope !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheBdouilleur picture TheBdouilleur  路  5Comments

Swicegood picture Swicegood  路  4Comments

MishaTreedye picture MishaTreedye  路  4Comments

ClayMDMI picture ClayMDMI  路  4Comments

JanStgmnn picture JanStgmnn  路  4Comments