Eel icon indicating copy to clipboard operation
Eel copied to clipboard

PLS HELP : Using Eel with a Svelte app

Open pramod-thaz opened this issue 5 years ago • 8 comments

Hi I am trying to use eel with a svelte app. However I keep getting this error. I saw that there is a sample for React; it would be a great help if you could guide me towards the proper use of this library with Svelte.

ERROR

Uncaught TypeError: Cannot read property 'length' of undefined at Object._mock_py_functions (eel.js:36) at Object._init (eel.js:108) at eel.js:166

SVELTE APP

<svelte:head>
	<script src="http://localhost:8080/eel.js" on:load={eelLoaded}></script>
</svelte:head>

<script>
const eelLoaded = () => {
		console.log("eel loaded");
		const eel = window.eel
		eel.set_host( 'ws://localhost:8080' )
		
		window.eel.expose(say_hello_js);
		eel.say_hello_py("Javascript World!");

	}
function say_hello_js(x) {
		console.log("Hello from " + x);
	}
        
	say_hello_js("Javascript World!");
</script>

PYTHON FILE

import eel

# Set web files folder
eel.init('public')

@eel.expose                         # Expose this function to Javascript
def say_hello_py(x):
    print('Hello from %s' % x)

#say_hello_py('Python World!')
#eel.say_hello_js('Python World!')   # Call a Javascript function

eel.start('index.html', size=(300, 200))  # Start

image

pramod-thaz avatar Sep 07 '20 19:09 pramod-thaz

Hi, I have the same problem, did you manage to fix it?

DaviAntonaji avatar Nov 25 '21 19:11 DaviAntonaji

Good afternoon, I managed to fix my problem here, if you still have it.

The error was because my eel.js file was in a subfolder. I left my home.html and eel.js file in the same directory and it ran perfectly.

DaviAntonaji avatar Nov 25 '21 19:11 DaviAntonaji

i need eel + svelte, could you share the the steps, configs, please

solisadeqi avatar Apr 02 '22 07:04 solisadeqi

Good afternoon, I managed to fix my problem here, if you still have it.

The error was because my eel.js file was in a subfolder. I left my home.html and eel.js file in the same directory and it ran perfectly.

I tried this but it did not work.

ZJUAlexChen avatar Dec 06 '22 21:12 ZJUAlexChen

I can't get it to work either. I tried to replicate how mochatek got eel+svelte working: https://github.com/mochatek/MovieSieve

But no matter what I do I get: AttributeError: module 'eel' has no attribute 'say_hello_js'

garfieldbanks avatar Jan 17 '23 23:01 garfieldbanks

I can't get it to work either. I tried to replicate how mochatek got eel+svelte working: https://github.com/mochatek/MovieSieve

But no matter what I do I get: AttributeError: module 'eel' has no attribute 'say_hello_js'

Maybe this could help: https://github.com/WiIIiamTang/create-sveltekit-eel-app It's with sveltekit though, but the setup could probably be the same?

WiIIiamTang avatar Jan 31 '23 03:01 WiIIiamTang

@WiIIiamTang Thanks! I'll take a look!

garfieldbanks avatar Jan 31 '23 04:01 garfieldbanks

I have the same issue trying to connect my python script to my svelte front end app..anyhelp?

joni-kano avatar Mar 29 '23 03:03 joni-kano