python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.5k stars 592 forks source link

Question: Call async Javascript function from Python #741

Open Pibben opened 2 months ago

Pibben commented 2 months ago

Maybe I'm stupid, but I don't understand how to call an async JS function from Python. For example:

eel.expose(test);
async function test() {
    console.log("Hello world!");
}

This does not work:

eel.test()
samuelhwilliams commented 2 months ago

Does this example help?

https://github.com/python-eel/Eel/blob/main/examples/03%20-%20sync_callbacks/web/sync_callbacks.html https://github.com/python-eel/Eel/blob/main/examples/03%20-%20sync_callbacks/sync_callbacks.py

Pibben commented 2 months ago

Does this example help?

https://github.com/python-eel/Eel/blob/main/examples/03%20-%20sync_callbacks/web/sync_callbacks.html https://github.com/python-eel/Eel/blob/main/examples/03%20-%20sync_callbacks/sync_callbacks.py

No I'm afraid that example goes the other way; calling python from JS.

Matthew-05 commented 2 months ago

Out of curiosity, can you give a more specific example of when you want to do something like this? I'm struggling to come up with a specific use case I would want to do this.