Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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)
def _websocket_close(page, old_websockets):
global stopped
print('A WebUI just closed. Checking for other connections... (%s)[%s]' % (page, len(old_websockets)))
for i in range(40):
eel.sleep(.1)
# noinspection PyProtectedMember
if len(eel._websockets) > 0:
print('Open connections still exist. Not stopping UI server.')
return
if not settings.get('interface.keep_open'):
print('WebUI keep_open is disabled, and all open clients have closed. Exiting.')
if _controller and _controller.is_alive():
_controller.stop()
stopped = True
else:
print('Keeping UI server open...')
def sleep(sec):
eel.sleep(sec)
def run(code, stdin=''):
while state['mode'] != 'stopped':
state['mode'] = 'interrupt'
eel.sleep(0.01)
state['mode'] = 'running'
sta.execution_start()
exe.bounded_exec(code, 10**7, report)
state['mode'] = 'stopped'
def display(self):
if started:
return False
webdir = os.path.join(os.path.dirname(__file__), '../web/')
start(web_dir=webdir)
while not stopped:
eel.sleep(1)