async def main(): # Use the same static files as the original Example os.chdir(os.path.join('..', '01 - hello_world')) # Set web files folder and optionally specify which file types to check for eel.expose() async_eel.init('web', allowed_extensions=['.js', '.html']) # Launch example in Microsoft Edge only on Windows 10 and above if sys.platform in ['win32', 'win64'] and int(platform.release()) >= 10: await async_eel.start('hello.html', mode='edge') else: raise EnvironmentError('Error: System is not Windows 10 or above') # # Launching Edge can also be gracefully handled as a fall back # try: # await async_eel.start('hello.html', mode='chrome-app', size=(300, 200)) # except EnvironmentError: # # If Chrome isn't found, fallback to Microsoft Edge on Win10 or greater # if sys.platform in ['win32', 'win64'] and int(platform.release()) >= 10: # await async_eel.start('hello.html', mode='edge') # else: # raise await say_hello_py('Python World!') await async_eel.say_hello_js('Python World!')( ) # Call a Javascript function print("OK")
async def main(): # Set web files folder and optionally specify which file types to check for eel.expose() async_eel.init('web') # disable_cache now defaults to True so this isn't strictly necessary. Set it to False to enable caching. await async_eel.start('disable_cache.html', size=(300, 200), disable_cache=True) # Start
async def main(): # Set web files folder async_eel.init('web') await async_eel.start('hello.html', size=(300, 200)) # Start await say_hello_py('Python World!') await async_eel.say_hello_js('Python World!')( ) # Call a Javascript function print("OK")
async def main(): async_eel.init('web') await async_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 data = await async_eel.js_random()() print('Got this from Javascript:', data)
async def main(): try: async_eel.init('web') # Give folder containing web files await async_eel.start('main.html', size=(500, 250)) # Start await async_eel.say_hello_js('connected!')( ) # Call a Javascript function print("OK") except Exception: import traceback traceback.print_exc()
async def main(): try: # Set web files folder async_eel.init('web') await async_eel.start('hello.html', options=options) # await eel.start('hello.html', mode='custom', cmdline_args=['node_modules/electron/dist/electron.exe', '.']) say_hello_py('Python World!') async_eel.say_hello_js('Python World!') # Call a Javascript function except Exception: import traceback traceback.print_exc()
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()
async def main(): try: async_eel.init('web') # Give folder containing web files await async_eel.start('templates/hello.html', size=(300, 200), jinja_templates='templates') # Start say_hello_py('Python World!') r = await async_eel.say_hello_js('Python World!')( ) # Call a Javascript function print("main OK", r) except Exception: import traceback traceback.print_exc()
async def start_eel(develop): """Start Eel with either production or development configuration.""" if develop: directory = 'src' app = None page = {'port': 3000} else: directory = 'build' app = 'chrome-app' page = 'index.html' async_eel.init(directory, ['.tsx', '.ts', '.jsx', '.js', '.html']) try: # These will be queued until the first connection is made, but won't be repeated on a page reload await say_hello_py('Python World!') async_eel.say_hello_js( 'Python World!' ) # Call a JavaScript function (must be after `eel.init()`) except Exception: import traceback traceback.print_exc() eel_kwargs = dict( host='localhost', port=8080, size=(1280, 800), ) try: await async_eel.start(page, mode=app, **eel_kwargs) except EnvironmentError: # If Chrome isn't found, fallback to Microsoft Edge on Win10 or greater if sys.platform in ['win32', 'win64' ] and int(platform.release()) >= 10: await async_eel.start(page, mode='edge', **eel_kwargs) else: raise
async def main(): async_eel.init('web') await async_eel.start('index.html', mode='edge') async_eel.spawn(callback_example) async_eel.spawn(loop_comment) log.info("success start app")
async def main(): async_eel.init('web') await async_eel.start('file_access.html', size=(320, 120))