start ( 'main.html' ) except ( SystemExit, MemoryError, KeyboardInterrupt ): # We can do something here if needed # But if we don't catch these safely, the script will crash pass print ( 'This is printed when the window is closed!' ) Why Use Eel? This is also helpful for creating thread in general.Īn example of using eel.sleep() and eel.spawn(): Use eel.spawn() to replace threading instances. To reduce the chance of conflicts, eel also provides a interface for creating threads. It has the exact same functionality, just it's one less import you need. Calling time.sleep() will pause the execution of the whole server so you should use eel.sleep() instead. ![]() Time.sleep() is very dangerous when used with eel fortunately we have been given an alternative. When clicked, this will call the getTime() function in python and then return the value back to JavaScript on the line let value = await eel.getTime()(). ![]() When running server.py, a chrome app window will appear with a button saying "Click to get time". expose ( my_javascript_function ) function my_javascript_function ( a, b ) Click to get time
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |