Open antrikshmisri opened 3 years ago
@ChrisKnott @samuelhwilliams Can you guys help me with this?
Found Solution!! @antrikshmisri
from
eel.expose(getFiles);
function getFiles(files)
{
files.map((file) => {
document.querySelector(".para").innerHTML += String(file);
});
}
to this
function getFiles(files)
{
files.map((file) => {
document.querySelector(".para").innerHTML += String(file);
});
}
window.eel.expose( getFiles, 'getFiles' )
Let me Know It Works or not
@amantiwari1 Thanks for the solution but unfortunately it is not working for me partly because of the way the eel is running. I think the issue is that python is trying to access a javascript function that has not been initialized yet. As python functions can be called by javascript (because running python functions from javascript gives eel enough time to expose the functions) , a workaround would be:-
function getFiles(files)
{
files.map((file) => {
document.querySelector(".para").innerHTML += String(file);
});
}
window.eel.expose( getFiles, 'getFiles' )
@eel.expose
def run_javascript():
eel.getFiles([args])
eel.run_javascript()
This doesn't give any errors but doesn't run the function either , i am stuck at this part and is bugging me alot 😞
@antrikshmisri, try this
def GetFiles():
eel.getFiles([args])
@eel.expose
def run_javascript():
GetFiles()
Let me Know It Works or not
If anyone still has this issue I found a solution that works for me. This is my eel init: eel.init('client/src/api', allowed_extensions=['.ts']). My Typescript function is directly under this path: client/src/api, I also needed to allow .ts extension, add js, jsx or tsx if needed. In my ts file my function looks like this:
eel.expose(getEmailsPortal) function getEmailsPortal(){ getEmails() }
I create a portal function for python to run another TS function because I dont think eel allows export, and async doesnt always run how I expect, but you can mess around with that.
Describe the problem I am trying to run eel with react using Eel-React-Template. I have a javascript function exposed in index.html but when I try to run the function from a python file I get the following error:
Code snippet(s) My directory structure is:-
│ .gitignore │ main.py │ rest of the files ├───public │------index.html │------rest of the files ├───src │-----App.js │-----eel.js │-----index.js │-----*rest of the files***
This is my
App.js
:-This is my
main.py
:-This is my
index.html
:-Desktop (please complete the following information):
Smartphone (please complete the following information):