Eel icon indicating copy to clipboard operation
Eel copied to clipboard

Question: Call async Javascript function from Python

Open Pibben opened this issue 1 year ago • 3 comments

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()

Pibben avatar Sep 09 '24 11:09 Pibben

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

samuelhwilliams avatar Sep 10 '24 12:09 samuelhwilliams

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.

Pibben avatar Sep 10 '24 13:09 Pibben

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.

Matthew-05 avatar Sep 16 '24 20:09 Matthew-05