python-eel/Eel

PLS HELP : Using Eel with a Svelte app

Open

#390 geöffnet am 7. Sept. 2020

Auf GitHub ansehen
 (8 Kommentare) (1 Reaktion) (0 zugewiesene Personen)Python (570 Forks)batch import
help wanted

Repository-Metriken

Stars
 (5.980 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide