Skip to content
This repository was archived by the owner on Jul 26, 2024. It is now read-only.

Commit 3978ff4

Browse files
authored
Merge pull request #2 from python-aal:1-rename-package-in-preparation-for-pypi-build
Refactor file paths and imports, update package name and author information
2 parents fce8c6a + 1a375fa commit 3978ff4

46 files changed

Lines changed: 410 additions & 408 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Eel
1+
name: Test Aal
22

33
on:
44
push:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ __pycache__
22
dist
33
build
44
Drivers
5-
Eel.egg-info
5+
Aal.egg-info
66
.tmp
77
.DS_Store
88
*.pyc

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
* Fix the implementation of #203, allowing users to pass their own bottle instances into Eel.
5151

5252
## v0.11.0
53-
* Added support for `app` parameter to `eel.start`, which will override the bottle app instance used to run eel. This
54-
allows developers to apply any middleware they wish to before handing over to eel.
55-
* Disable page caching by default via new `disable_cache` parameter to `eel.start`.
56-
* Add support for listening on all network interfaces via new `all_interfaces` parameter to `eel.start`.
53+
* Added support for `app` parameter to `aal.start`, which will override the bottle app instance used to run aal. This
54+
allows developers to apply any middleware they wish to before handing over to aal.
55+
* Disable page caching by default via new `disable_cache` parameter to `aal.start`.
56+
* Add support for listening on all network interfaces via new `all_interfaces` parameter to `aal.start`.
5757
* Support for Microsoft Edge
5858

5959
### v0.10.4
@@ -70,7 +70,7 @@ allows developers to apply any middleware they wish to before handing over to ee
7070

7171
## v0.10.0
7272
* Corrective version bump after new feature included in 0.9.13
73-
* Fix a bug with example 06 for Jinja templating; the `templates` kwarg to `eel.start` takes a filepath, not a bool.
73+
* Fix a bug with example 06 for Jinja templating; the `templates` kwarg to `aal.start` takes a filepath, not a bool.
7474

7575
### v0.9.13
7676
* Add support for Jinja templating.

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ Suppose you put all the frontend files in a directory called `web`, including yo
8585

8686
```python
8787
import eel
88-
eel.init('web')
89-
eel.start('main.html')
88+
aal.init('web')
89+
aal.start('main.html')
9090
```
9191

9292
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
9595

9696
### App options
9797

98-
Additional options can be passed to `eel.start()` as keyword arguments.
98+
Additional options can be passed to `aal.start()` as keyword arguments.
9999

100100
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.
101101

@@ -105,30 +105,30 @@ As of Eel v0.12.0, the following options are available to `start()`:
105105
- **port**, an int specifying what port to use for the Bottle server. Use `0` for port to be picked automatically. *Default: `8000`*.
106106
- **block**, a bool saying whether or not the call to `start()` should block the calling thread. *Default: `True`*
107107
- **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: `[]`*
109109
- **size**, a tuple of ints specifying the (width, height) of the main window in pixels *Default: `None`*
110110
- **position**, a tuple of ints specifying the (left, top) of the main window in pixels *Default: `None`*
111111
- **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: {}*
112112
- **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.
114114
- **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
115115

116116

117117

118118
### Exposing functions
119119

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:
121121

122122
```html
123-
<script type="text/javascript" src="/eel.js"></script>
123+
<script type="text/javascript" src="/aal.js"></script>
124124
```
125125

126126
Including this library creates an `eel` object which can be used to communicate with the Python side.
127127

128-
Any functions in the Python code which are decorated with `@eel.expose` like this...
128+
Any functions in the Python code which are decorated with `@aal.expose` like this...
129129

130130
```python
131-
@eel.expose
131+
@aal.expose
132132
def my_python_function(a, b):
133133
print(a, b, a + b)
134134
```
@@ -137,13 +137,13 @@ def my_python_function(a, b):
137137

138138
```javascript
139139
console.log("Calling Python...");
140-
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
141141
```
142142

143143
Similarly, any Javascript functions which are exposed like this...
144144

145145
```javascript
146-
eel.expose(my_javascript_function);
146+
aal.expose(my_javascript_function);
147147
function my_javascript_function(a, b, c, d) {
148148
if (a < b) {
149149
console.log(c * d);
@@ -155,13 +155,13 @@ can be called from the Python side like this...
155155

156156
```python
157157
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
159159
```
160160

161161
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:
162162

163163
```javascript
164-
eel.expose(someFunction, "my_javascript_function");
164+
aal.expose(someFunction, "my_javascript_function");
165165
```
166166

167167
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
178178
<head>
179179
<title>Hello, World!</title>
180180

181-
<!-- Include eel.js - note this file doesn't exist in the 'web' directory -->
182-
<script type="text/javascript" src="/eel.js"></script>
181+
<!-- Include aal.js - note this file doesn't exist in the 'web' directory -->
182+
<script type="text/javascript" src="/aal.js"></script>
183183
<script type="text/javascript">
184-
eel.expose(say_hello_js); // Expose this function to Python
184+
aal.expose(say_hello_js); // Expose this function to Python
185185
function say_hello_js(x) {
186186
console.log("Hello from " + x);
187187
}
188188
189189
say_hello_js("Javascript World!");
190-
eel.say_hello_py("Javascript World!"); // Call a Python function
190+
aal.say_hello_py("Javascript World!"); // Call a Python function
191191
</script>
192192
</head>
193193

@@ -202,18 +202,18 @@ and a short Python script `hello.py`:
202202
```python
203203
import eel
204204

205-
# Set web files folder and optionally specify which file types to check for eel.expose()
205+
# Set web files folder and optionally specify which file types to check for aal.expose()
206206
# *Default allowed_extensions are: ['.js', '.html', '.txt', '.htm', '.xhtml']
207-
eel.init('web', allowed_extensions=['.js', '.html'])
207+
aal.init('web', allowed_extensions=['.js', '.html'])
208208

209-
@eel.expose # Expose this function to Javascript
209+
@aal.expose # Expose this function to Javascript
210210
def say_hello_py(x):
211211
print('Hello from %s' % x)
212212

213213
say_hello_py('Python World!')
214-
eel.say_hello_js('Python World!') # Call a Javascript function
214+
aal.say_hello_js('Python World!') # Call a Javascript function
215215

216-
eel.start('hello.html') # Start (this blocks and enters loop)
216+
aal.start('hello.html') # Start (this blocks and enters loop)
217217
```
218218

219219
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
241241
Eel supports two ways of retrieving _return values_ from the other side of the app, which helps keep the code concise.
242242

243243
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.
245245

246246
#### Callbacks
247247

@@ -250,7 +250,7 @@ When you call an exposed function, you can immediately pass a callback function
250250
For example, if we have the following function defined and exposed in Javascript:
251251

252252
```javascript
253-
eel.expose(js_random);
253+
aal.expose(js_random);
254254
function js_random() {
255255
return Math.random();
256256
}
@@ -263,10 +263,10 @@ def print_num(n):
263263
print('Got this from Javascript:', n)
264264

265265
# Call Javascript function, and pass explicit callback function
266-
eel.js_random()(print_num)
266+
aal.js_random()(print_num)
267267

268268
# Do the same with an inline lambda as callback
269-
eel.js_random()(lambda n: print('Got this from Javascript:', n))
269+
aal.js_random()(lambda n: print('Got this from Javascript:', n))
270270
```
271271

272272
(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
278278
To synchronously retrieve the return value, simply pass nothing to the second set of brackets. So in Python we would write:
279279

280280
```python
281-
n = eel.js_random()() # This immediately returns the value
281+
n = aal.js_random()() # This immediately returns the value
282282
print('Got this from Javascript:', n)
283283
```
284284

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.
286286

287287
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:
288288

289289
```javascript
290290
async function run() {
291291
// Inside a function marked 'async' we can use the 'await' keyword.
292292

293-
let n = await eel.py_random()(); // Must prefix call with 'await', otherwise it's the same syntax
293+
let n = await aal.py_random()(); // Must prefix call with 'await', otherwise it's the same syntax
294294
console.log("Got this from Python: " + n);
295295
}
296296

@@ -307,20 +307,20 @@ In this example...
307307

308308
```python
309309
import eel
310-
eel.init('web')
310+
aal.init('web')
311311

312312
def my_other_thread():
313313
while True:
314314
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()
316316

317-
eel.spawn(my_other_thread)
317+
aal.spawn(my_other_thread)
318318

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
320320

321321
while True:
322322
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()
324324
```
325325

326326
...we would then have three "threads" (greenlets) running;
@@ -344,7 +344,7 @@ Consult the [documentation for PyInstaller](http://PyInstaller.readthedocs.io/en
344344

345345
## Microsoft Edge
346346

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:
348348

349349
- 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)
350350
- 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

Comments
 (0)