Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commented lines of code changing eel behavior (actually) #706

Open
panthuncia opened this issue Oct 11, 2023 · 0 comments
Open

Commented lines of code changing eel behavior (actually) #706

panthuncia opened this issue Oct 11, 2023 · 0 comments
Labels

Comments

@panthuncia
Copy link

panthuncia commented Oct 11, 2023

Eel version
0.16.0
Describe the bug
Commented lines of code changes how Eel executes under very specific circumstances involving functions generated at runtime. These functions seem to require two eel.expose calls to be exposed properly, but only the first needs to execute. The second can be commented.

I'm not sure if the code I'm writing should work or not, but it definitely shouldn't do this.

To Reproduce
Steps to reproduce the behavior:

create a div like this:

<div class="div_class" id="SomeDiv">
    <p>SomeDiv</p>
</div>

and as many more of that class as you would like

Define functions in a loop like this:

for (const div of document.getElementsByClassName("div_class")){
    funcName = div.id+"Func"
    window[funcName] = () => {
        console.log("In function")
    }
    eel.expose(window[funcName], funcName)
}
//eel.expose(SomeDivFunc)

and call the function from Python.
This should work (it does for me).

Now, remove the commented line.

for (const div of document.getElementsByClassName("div_class")){
    funcName = div.id+"Func"
    window[funcName] = () => {
        console.log("In function")
    }
    eel.expose(window[funcName], funcName)
}

Now, eel fails to load the function, and we get "module 'eel' has no attribute '<name>'".

Now, if we uncomment that line, and comment or remove the first eel.expose:

for (const div of document.getElementsByClassName("div_class")){
    funcName = div.id+"Func"
    window[funcName] = () => {
        console.log("In function")
    }
    //eel.expose(window[funcName], funcName)
}
eel.expose(SomeDivFunc)

The app will execute, and the python call will not generate an error, but the function will not be executed.

Expected behavior
The commented line should have no impact on code execution, as it is commented.

Additionally, it is strange that this functionality requires both of these eel.expose calls for the function to be exposed successfully. Neither expose alone works, but the second one can be commented and it will still work.

Is this even supposed to work? It is a somewhat strange use-case.

System Information

  • OS: Windows 11 x64
  • Browser: Chrome
  • Python Distribution: Python 3.11
@panthuncia panthuncia added the bug label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant