from __future__ import print_function	# For Py2/3 compatibility
import async_eel
import random
import asyncio


loop = asyncio.get_event_loop()


@async_eel.expose
async def py_random():
    return random.random()


async def print_num(n):
    """callback of js_random"""
    print('Got this from Javascript:', n)


async def main():
    try:
        async_eel.init('web')
        await async_eel.start('callbacks.html', size=(400, 300))

        # Call Javascript function, and pass explicit callback function
        await async_eel.js_random()(print_num)

        # Do the same with an inline callback
        await async_eel.js_random()(lambda n: print('2Got this from Javascript:', n))
    except Exception:
        import traceback
        traceback.print_exc()


if __name__ == '__main__':
    asyncio.run_coroutine_threadsafe(main(), loop)
    loop.run_forever()

[(7, 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), False, 'import asyncio\n'), (12, 'random.random', 'random.random', ([], {}), False, 'import random\n'), (22, 'async_eel.init', 'async_eel.init', (['"""web"""'], {}), False, 'import async_eel\n'), (23, 'async_eel.start', 'async_eel.start', (['"""callbacks.html"""'], {'size': '(400, 300)'}), False, 'import async_eel\n'), (32, 'traceback.print_exc', 'traceback.print_exc', ([], {}), False, 'import traceback\n'), (26, 'async_eel.js_random', 'async_eel.js_random', ([], {}), False, 'import async_eel\n'), (29, 'async_eel.js_random', 'async_eel.js_random', ([], {}), False, 'import async_eel\n')]