You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 26, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+35-35Lines changed: 35 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,8 +85,8 @@ Suppose you put all the frontend files in a directory called `web`, including yo
85
85
86
86
```python
87
87
import eel
88
-
eel.init('web')
89
-
eel.start('main.html')
88
+
aal.init('web')
89
+
aal.start('main.html')
90
90
```
91
91
92
92
This will start a webserver on the default settings (http://localhost:8000) and open a browser to http://localhost:8000/main.html.
@@ -95,7 +95,7 @@ If Chrome or Chromium is installed then by default it will open in that in App M
95
95
96
96
### App options
97
97
98
-
Additional options can be passed to `eel.start()` as keyword arguments.
98
+
Additional options can be passed to `aal.start()` as keyword arguments.
99
99
100
100
Some of the options include the mode the app is in (e.g. 'chrome'), the port the app runs on, the host name of the app, and adding additional command line flags.
101
101
@@ -105,30 +105,30 @@ As of Eel v0.12.0, the following options are available to `start()`:
105
105
-**port**, an int specifying what port to use for the Bottle server. Use `0` for port to be picked automatically. *Default: `8000`*.
106
106
-**block**, a bool saying whether or not the call to `start()` should block the calling thread. *Default: `True`*
107
107
-**jinja_templates**, a string specifying a folder to use for Jinja2 templates, e.g. `my_templates`. *Default: `None`*
108
-
-**cmdline_args**, a list of strings to pass to the command to start the browser. For example, we might add extra flags for Chrome; ```eel.start('main.html', mode='chrome-app', port=8080, cmdline_args=['--start-fullscreen', '--browser-startup-dialog'])```. *Default: `[]`*
108
+
-**cmdline_args**, a list of strings to pass to the command to start the browser. For example, we might add extra flags for Chrome; ```aal.start('main.html', mode='chrome-app', port=8080, cmdline_args=['--start-fullscreen', '--browser-startup-dialog'])```. *Default: `[]`*
109
109
-**size**, a tuple of ints specifying the (width, height) of the main window in pixels *Default: `None`*
110
110
-**position**, a tuple of ints specifying the (left, top) of the main window in pixels *Default: `None`*
111
111
-**geometry**, a dictionary specifying the size and position for all windows. The keys should be the relative path of the page, and the values should be a dictionary of the form `{'size': (200, 100), 'position': (300, 50)}`. *Default: {}*
112
112
-**close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`*
113
-
-**app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the instance before starting eel, e.g. for session management, authentication, etc. If your `app` is not a Bottle instance, you will need to call `eel.register_eel_routes(app)` on your custom app instance.
113
+
-**app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the instance before starting eel, e.g. for session management, authentication, etc. If your `app` is not a Bottle instance, you will need to call `aal.register_eel_routes(app)` on your custom app instance.
114
114
-**shutdown_delay**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `shutdown_delay` seconds, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. By default, the value of **shutdown_delay** is `1.0` second
115
115
116
116
117
117
118
118
### Exposing functions
119
119
120
-
In addition to the files in the frontend folder, a Javascript library will be served at `/eel.js`. You should include this in any pages:
120
+
In addition to the files in the frontend folder, a Javascript library will be served at `/aal.js`. You should include this in any pages:
eel.my_python_function(1, 2); // This calls the Python function that was decorated
140
+
aal.my_python_function(1, 2); // This calls the Python function that was decorated
141
141
```
142
142
143
143
Similarly, any Javascript functions which are exposed like this...
144
144
145
145
```javascript
146
-
eel.expose(my_javascript_function);
146
+
aal.expose(my_javascript_function);
147
147
functionmy_javascript_function(a, b, c, d) {
148
148
if (a < b) {
149
149
console.log(c * d);
@@ -155,13 +155,13 @@ can be called from the Python side like this...
155
155
156
156
```python
157
157
print('Calling Javascript...')
158
-
eel.my_javascript_function(1, 2, 3, 4) # This calls the Javascript function
158
+
aal.my_javascript_function(1, 2, 3, 4) # This calls the Javascript function
159
159
```
160
160
161
161
The exposed name can also be overridden by passing in a second argument. If your app minifies JavaScript during builds, this may be necessary to ensure that functions can be resolved on the Python side:
When passing complex objects as arguments, bear in mind that internally they are converted to JSON and sent down a websocket (a process that potentially loses information).
@@ -178,16 +178,16 @@ Putting this together into a **Hello, World!** example, we have a short HTML pag
178
178
<head>
179
179
<title>Hello, World!</title>
180
180
181
-
<!-- Include eel.js - note this file doesn't exist in the 'web' directory -->
eel.say_hello_js('Python World!') # Call a Javascript function
214
+
aal.say_hello_js('Python World!') # Call a Javascript function
215
215
216
-
eel.start('hello.html') # Start (this blocks and enters loop)
216
+
aal.start('hello.html') # Start (this blocks and enters loop)
217
217
```
218
218
219
219
If we run the Python script (`python hello.py`), then a browser window will open displaying `hello.html`, and we will see...
@@ -241,7 +241,7 @@ While we want to think of our code as comprising a single application, the Pytho
241
241
Eel supports two ways of retrieving _return values_ from the other side of the app, which helps keep the code concise.
242
242
243
243
To prevent hanging forever on the Python side, a timeout has been put in place for trying to retrieve values from
244
-
the JavaScript side, which defaults to 10000 milliseconds (10 seconds). This can be changed with the `_js_result_timeout` parameter to `eel.init`. There is no corresponding timeout on the JavaScript side.
244
+
the JavaScript side, which defaults to 10000 milliseconds (10 seconds). This can be changed with the `_js_result_timeout` parameter to `aal.init`. There is no corresponding timeout on the JavaScript side.
245
245
246
246
#### Callbacks
247
247
@@ -250,7 +250,7 @@ When you call an exposed function, you can immediately pass a callback function
250
250
For example, if we have the following function defined and exposed in Javascript:
251
251
252
252
```javascript
253
-
eel.expose(js_random);
253
+
aal.expose(js_random);
254
254
functionjs_random() {
255
255
returnMath.random();
256
256
}
@@ -263,10 +263,10 @@ def print_num(n):
263
263
print('Got this from Javascript:', n)
264
264
265
265
# Call Javascript function, and pass explicit callback function
266
-
eel.js_random()(print_num)
266
+
aal.js_random()(print_num)
267
267
268
268
# Do the same with an inline lambda as callback
269
-
eel.js_random()(lambdan: print('Got this from Javascript:', n))
269
+
aal.js_random()(lambdan: print('Got this from Javascript:', n))
270
270
```
271
271
272
272
(It works exactly the same the other way around).
@@ -278,19 +278,19 @@ In most situations, the calls to the other side are to quickly retrieve some pie
278
278
To synchronously retrieve the return value, simply pass nothing to the second set of brackets. So in Python we would write:
279
279
280
280
```python
281
-
n =eel.js_random()() # This immediately returns the value
281
+
n =aal.js_random()() # This immediately returns the value
282
282
print('Got this from Javascript:', n)
283
283
```
284
284
285
-
You can only perform synchronous returns after the browser window has started (after calling `eel.start()`), otherwise obviously the call will hang.
285
+
You can only perform synchronous returns after the browser window has started (after calling `aal.start()`), otherwise obviously the call will hang.
286
286
287
287
In Javascript, the language doesn't allow us to block while we wait for a callback, except by using `await` from inside an `async` function. So the equivalent code from the Javascript side would be:
288
288
289
289
```javascript
290
290
asyncfunctionrun() {
291
291
// Inside a function marked 'async' we can use the 'await' keyword.
292
292
293
-
let n =awaiteel.py_random()(); // Must prefix call with 'await', otherwise it's the same syntax
293
+
let n =awaitaal.py_random()(); // Must prefix call with 'await', otherwise it's the same syntax
294
294
console.log("Got this from Python: "+ n);
295
295
}
296
296
@@ -307,20 +307,20 @@ In this example...
307
307
308
308
```python
309
309
import eel
310
-
eel.init('web')
310
+
aal.init('web')
311
311
312
312
defmy_other_thread():
313
313
whileTrue:
314
314
print("I'm a thread")
315
-
eel.sleep(1.0) # Use eel.sleep(), not time.sleep()
315
+
aal.sleep(1.0) # Use aal.sleep(), not time.sleep()
316
316
317
-
eel.spawn(my_other_thread)
317
+
aal.spawn(my_other_thread)
318
318
319
-
eel.start('main.html', block=False) # Don't block on this call
319
+
aal.start('main.html', block=False) # Don't block on this call
320
320
321
321
whileTrue:
322
322
print("I'm a main loop")
323
-
eel.sleep(1.0) # Use eel.sleep(), not time.sleep()
323
+
aal.sleep(1.0) # Use aal.sleep(), not time.sleep()
324
324
```
325
325
326
326
...we would then have three "threads" (greenlets) running;
@@ -344,7 +344,7 @@ Consult the [documentation for PyInstaller](http://PyInstaller.readthedocs.io/en
344
344
345
345
## Microsoft Edge
346
346
347
-
For Windows 10 users, Microsoft Edge (`eel.start(.., mode='edge')`) is installed by default and a useful fallback if a preferred browser is not installed. See the examples:
347
+
For Windows 10 users, Microsoft Edge (`aal.start(.., mode='edge')`) is installed by default and a useful fallback if a preferred browser is not installed. See the examples:
348
348
349
349
- A Hello World example using Microsoft Edge: [examples/01 - hello_world-Edge/](https://github.com/ChrisKnott/Eel/tree/master/examples/01%20-%20hello_world-Edge)
350
350
- Example implementing browser-fallbacks: [examples/07 - CreateReactApp/eel_CRA.py](https://github.com/ChrisKnott/Eel/tree/master/examples/07%20-%20CreateReactApp/eel_CRA.py)
0 commit comments