How to use the eel.js_random function in Eel

To help you get started, we’ve selected a few Eel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelhwilliams / Eel / examples / 02 - callbacks / callbacks.py View on Github external
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))
github samuelhwilliams / Eel / examples / 03 - sync_callbacks / sync_callbacks.py View on Github external
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)