Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from __future__ import print_function # For Py2/3 compatibility
import eel
import random
eel.init('web')
@eel.expose
def py_random():
return random.random()
def print_num(n):
print('Got this from Javascript:', n)
# Call Javascript function, and pass explicit callback function
eel.js_random()(print_num)
# Do the same with an inline callback
eel.js_random()(lambda n: print('Got this from Javascript:', n))
eel.start('callbacks.html', size=(400, 300))
import eel, random
eel.init('web')
@eel.expose
def py_random():
return random.random()
eel.start('sync_callbacks.html', block=False, size=(400, 300))
# Synchronous calls must happen after start() is called
# Get result returned synchronously by
# passing nothing in second brackets
# v
n = eel.js_random()()
print('Got this from Javascript:', n)
while True:
eel.sleep(1.0)