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

Commit 0b23f9f

Browse files
committed
version bump
1 parent 4a8b4c6 commit 0b23f9f

33 files changed

Lines changed: 397 additions & 376 deletions

File tree

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 `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`.
53+
* Added support for `app` parameter to `paling.start`, which will override the bottle app instance used to run paling. This
54+
allows developers to apply any middleware they wish to before handing over to paling.
55+
* Disable page caching by default via new `disable_cache` parameter to `paling.start`.
56+
* Add support for listening on all network interfaces via new `all_interfaces` parameter to `paling.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 aa
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 `aal.start` takes a filepath, not a bool.
73+
* Fix a bug with example 06 for Jinja templating; the `templates` kwarg to `paling.start` takes a filepath, not a bool.
7474

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

README.md

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Eel, but then Aal
1+
# Eel, but then Paling
22

3-
[![PyPI version](https://img.shields.io/pypi/v/Eel?style=for-the-badge)](https://pypi.org/project/Eel/)
4-
[![PyPi Downloads](https://img.shields.io/pypi/dm/Eel?style=for-the-badge)](https://pypistats.org/packages/eel)
5-
![Python](https://img.shields.io/pypi/pyversions/Eel?style=for-the-badge)
6-
[![License](https://img.shields.io/pypi/l/Eel.svg?style=for-the-badge)](https://pypi.org/project/Eel/)
3+
[![PyPI version](https://img.shields.io/pypi/v/Eel?style=for-the-badge)](https://pypi.org/project/Paling/)
4+
[![PyPi Downloads](https://img.shields.io/pypi/dm/Eel?style=for-the-badge)](https://pypistats.org/packages/paling)
5+
![Python](https://img.shields.io/pypi/pyversions/Paling?style=for-the-badge)
6+
[![License](https://img.shields.io/pypi/l/Eel.svg?style=for-the-badge)](https://pypi.org/project/Paling/)
77

8-
Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries.
8+
Paling is a updated version of Eel, the Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries.
99

1010
> **Eel hosts a local webserver, then lets you annotate functions in Python so that they can be called from Javascript, and vice versa.**
1111
@@ -36,6 +36,8 @@ Eel is designed to take the hassle out of writing short and simple GUI applicati
3636

3737
## Intro
3838

39+
Eel has always been our favorite library for writing UI's in python, because it made it very simple to create a beautiful interface. Unfortunately the project has not been maintained, and now we are taking over.
40+
3941
There are several options for making GUI apps in Python, but if you want to use HTML/JS (in order to use jQueryUI or Bootstrap, for example) then you generally have to write a lot of boilerplate code to communicate from the Client (Javascript) side to the Server (Python) side.
4042

4143
The closest Python equivalent to Electron (to my knowledge) is [cefpython](https://github.com/cztomczak/cefpython). It is a bit heavy weight for what I wanted.
@@ -51,7 +53,7 @@ Join Eel's users and maintainers on [Discord](https://discord.com/invite/3nqXPFX
5153
Install from pypi with `pip`:
5254

5355
```shell
54-
pip install eel
56+
pip install paling
5557
```
5658

5759
To include support for HTML templating, currently using [Jinja2](https://pypi.org/project/Jinja2/#description):
@@ -85,8 +87,8 @@ Suppose you put all the frontend files in a directory called `web`, including yo
8587

8688
```python
8789
import eel
88-
aal.init('web')
89-
aal.start('main.html')
90+
paling.init('web')
91+
paling.start('main.html')
9092
```
9193

9294
This will start a webserver on the default settings (http://localhost:8000) and open a browser to http://localhost:8000/main.html.
@@ -95,7 +97,7 @@ If Chrome or Chromium is installed then by default it will open in that in App M
9597

9698
### App options
9799

98-
Additional options can be passed to `aal.start()` as keyword arguments.
100+
Additional options can be passed to `paling.start()` as keyword arguments.
99101

100102
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.
101103

@@ -105,30 +107,30 @@ As of Eel v0.12.0, the following options are available to `start()`:
105107
- **port**, an int specifying what port to use for the Bottle server. Use `0` for port to be picked automatically. *Default: `8000`*.
106108
- **block**, a bool saying whether or not the call to `start()` should block the calling thread. *Default: `True`*
107109
- **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; ```aal.start('main.html', mode='chrome-app', port=8080, cmdline_args=['--start-fullscreen', '--browser-startup-dialog'])```. *Default: `[]`*
110+
- **cmdline_args**, a list of strings to pass to the command to start the browser. For example, we might add extra flags for Chrome; ```paling.start('main.html', mode='chrome-app', port=8080, cmdline_args=['--start-fullscreen', '--browser-startup-dialog'])```. *Default: `[]`*
109111
- **size**, a tuple of ints specifying the (width, height) of the main window in pixels *Default: `None`*
110112
- **position**, a tuple of ints specifying the (left, top) of the main window in pixels *Default: `None`*
111113
- **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: {}*
112114
- **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 `aal.register_eel_routes(app)` on your custom app instance.
115+
- **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 `paling.register_eel_routes(app)` on your custom app instance.
114116
- **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
115117

116118

117119

118120
### Exposing functions
119121

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:
122+
In addition to the files in the frontend folder, a Javascript library will be served at `/paling.js`. You should include this in any pages:
121123

122124
```html
123-
<script type="text/javascript" src="/aal.js"></script>
125+
<script type="text/javascript" src="/paling.js"></script>
124126
```
125127

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

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

130132
```python
131-
@aal.expose
133+
@paling.expose
132134
def my_python_function(a, b):
133135
print(a, b, a + b)
134136
```
@@ -137,13 +139,13 @@ def my_python_function(a, b):
137139

138140
```javascript
139141
console.log("Calling Python...");
140-
aal.my_python_function(1, 2); // This calls the Python function that was decorated
142+
paling.my_python_function(1, 2); // This calls the Python function that was decorated
141143
```
142144

143145
Similarly, any Javascript functions which are exposed like this...
144146

145147
```javascript
146-
aal.expose(my_javascript_function);
148+
paling.expose(my_javascript_function);
147149
function my_javascript_function(a, b, c, d) {
148150
if (a < b) {
149151
console.log(c * d);
@@ -155,13 +157,13 @@ can be called from the Python side like this...
155157

156158
```python
157159
print('Calling Javascript...')
158-
aal.my_javascript_function(1, 2, 3, 4) # This calls the Javascript function
160+
paling.my_javascript_function(1, 2, 3, 4) # This calls the Javascript function
159161
```
160162

161163
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:
162164

163165
```javascript
164-
aal.expose(someFunction, "my_javascript_function");
166+
paling.expose(someFunction, "my_javascript_function");
165167
```
166168

167169
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 +180,16 @@ Putting this together into a **Hello, World!** example, we have a short HTML pag
178180
<head>
179181
<title>Hello, World!</title>
180182

181-
<!-- Include aal.js - note this file doesn't exist in the 'web' directory -->
182-
<script type="text/javascript" src="/aal.js"></script>
183+
<!-- Include paling.js - note this file doesn't exist in the 'web' directory -->
184+
<script type="text/javascript" src="/paling.js"></script>
183185
<script type="text/javascript">
184-
aal.expose(say_hello_js); // Expose this function to Python
186+
paling.expose(say_hello_js); // Expose this function to Python
185187
function say_hello_js(x) {
186188
console.log("Hello from " + x);
187189
}
188190
189191
say_hello_js("Javascript World!");
190-
aal.say_hello_py("Javascript World!"); // Call a Python function
192+
paling.say_hello_py("Javascript World!"); // Call a Python function
191193
</script>
192194
</head>
193195

@@ -202,18 +204,18 @@ and a short Python script `hello.py`:
202204
```python
203205
import eel
204206

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

209-
@aal.expose # Expose this function to Javascript
211+
@paling.expose # Expose this function to Javascript
210212
def say_hello_py(x):
211213
print('Hello from %s' % x)
212214

213215
say_hello_py('Python World!')
214-
aal.say_hello_js('Python World!') # Call a Javascript function
216+
paling.say_hello_js('Python World!') # Call a Javascript function
215217

216-
aal.start('hello.html') # Start (this blocks and enters loop)
218+
paling.start('hello.html') # Start (this blocks and enters loop)
217219
```
218220

219221
If we run the Python script (`python hello.py`), then a browser window will open displaying `hello.html`, and we will see...
@@ -241,7 +243,7 @@ While we want to think of our code as comprising a single application, the Pytho
241243
Eel supports two ways of retrieving _return values_ from the other side of the app, which helps keep the code concise.
242244

243245
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 `aal.init`. There is no corresponding timeout on the JavaScript side.
246+
the JavaScript side, which defaults to 10000 milliseconds (10 seconds). This can be changed with the `_js_result_timeout` parameter to `paling.init`. There is no corresponding timeout on the JavaScript side.
245247

246248
#### Callbacks
247249

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

252254
```javascript
253-
aal.expose(js_random);
255+
paling.expose(js_random);
254256
function js_random() {
255257
return Math.random();
256258
}
@@ -263,10 +265,10 @@ def print_num(n):
263265
print('Got this from Javascript:', n)
264266

265267
# Call Javascript function, and pass explicit callback function
266-
aal.js_random()(print_num)
268+
paling.js_random()(print_num)
267269

268270
# Do the same with an inline lambda as callback
269-
aal.js_random()(lambda n: print('Got this from Javascript:', n))
271+
paling.js_random()(lambda n: print('Got this from Javascript:', n))
270272
```
271273

272274
(It works exactly the same the other way around).
@@ -278,19 +280,19 @@ In most situations, the calls to the other side are to quickly retrieve some pie
278280
To synchronously retrieve the return value, simply pass nothing to the second set of brackets. So in Python we would write:
279281

280282
```python
281-
n = aal.js_random()() # This immediately returns the value
283+
n = paling.js_random()() # This immediately returns the value
282284
print('Got this from Javascript:', n)
283285
```
284286

285-
You can only perform synchronous returns after the browser window has started (after calling `aal.start()`), otherwise obviously the call will hang.
287+
You can only perform synchronous returns after the browser window has started (after calling `paling.start()`), otherwise obviously the call will hang.
286288

287289
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:
288290

289291
```javascript
290292
async function run() {
291293
// Inside a function marked 'async' we can use the 'await' keyword.
292294

293-
let n = await aal.py_random()(); // Must prefix call with 'await', otherwise it's the same syntax
295+
let n = await paling.py_random()(); // Must prefix call with 'await', otherwise it's the same syntax
294296
console.log("Got this from Python: " + n);
295297
}
296298

@@ -307,20 +309,20 @@ In this example...
307309

308310
```python
309311
import eel
310-
aal.init('web')
312+
paling.init('web')
311313

312314
def my_other_thread():
313315
while True:
314316
print("I'm a thread")
315-
aal.sleep(1.0) # Use aal.sleep(), not time.sleep()
317+
paling.sleep(1.0) # Use paling.sleep(), not time.sleep()
316318

317-
aal.spawn(my_other_thread)
319+
paling.spawn(my_other_thread)
318320

319-
aal.start('main.html', block=False) # Don't block on this call
321+
paling.start('main.html', block=False) # Don't block on this call
320322

321323
while True:
322324
print("I'm a main loop")
323-
aal.sleep(1.0) # Use aal.sleep(), not time.sleep()
325+
paling.sleep(1.0) # Use paling.sleep(), not time.sleep()
324326
```
325327

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

345347
## Microsoft Edge
346348

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:
349+
For Windows 10 users, Microsoft Edge (`paling.start(.., mode='edge')`) is installed by default and a useful fallback if a preferred browser is not installed. See the examples:
348350

349351
- 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)
350352
- Example implementing browser-fallbacks: [examples/07 - CreateReactApp/eel_CRA.py](https://github.com/ChrisKnott/Eel/tree/master/examples/07%20-%20CreateReactApp/eel_CRA.py)

examples/01 - hello_world-Edge/hello.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@
99
# Use the same static files as the original Example
1010
os.chdir(os.path.join('..', '01 - hello_world'))
1111

12-
# Set web files folder and optionally specify which file types to check for aal.expose()
13-
aal.init('web', allowed_extensions=['.js', '.html'])
12+
# Set web files folder and optionally specify which file types to check for paling.expose()
13+
paling.init('web', allowed_extensions=['.js', '.html'])
1414

1515

16-
@aal.expose # Expose this function to Javascript
16+
@paling.expose # Expose this function to Javascript
1717
def say_hello_py(x):
1818
print('Hello from %s' % x)
1919

2020

2121
say_hello_py('Python World!')
22-
aal.say_hello_js('Python World!') # Call a Javascript function
22+
paling.say_hello_js('Python World!') # Call a Javascript function
2323

2424
# Launch example in Microsoft Edge only on Windows 10 and above
2525
if sys.platform in ['win32', 'win64'] and int(platform.release()) >= 10:
26-
aal.start('hello.html', mode='edge')
26+
paling.start('hello.html', mode='edge')
2727
else:
2828
raise EnvironmentError('Error: System is not Windows 10 or above')
2929

3030
# # Launching Edge can also be gracefully handled as a fall back
3131
# try:
32-
# aal.start('hello.html', mode='chrome-app', size=(300, 200))
32+
# paling.start('hello.html', mode='chrome-app', size=(300, 200))
3333
# except EnvironmentError:
3434
# # If Chrome isn't found, fallback to Microsoft Edge on Win10 or greater
3535
# if sys.platform in ['win32', 'win64'] and int(platform.release()) >= 10:
36-
# aal.start('hello.html', mode='edge')
36+
# paling.start('hello.html', mode='edge')
3737
# else:
3838
# raise

examples/01 - hello_world/hello.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import aal
22

33
# Set web files folder
4-
aal.init('web')
4+
paling.init('web')
55

6-
@aal.expose # Expose this function to Javascript
6+
@paling.expose # Expose this function to Javascript
77
def say_hello_py(x):
88
print('Hello from %s' % x)
99

1010
say_hello_py('Python World!')
11-
aal.say_hello_js('Python World!') # Call a Javascript function
11+
paling.say_hello_js('Python World!') # Call a Javascript function
1212

13-
aal.start('hello.html', size=(300, 200)) # Start
13+
paling.start('hello.html', size=(300, 200)) # Start
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title>Hello, World!</title>
5-
6-
<!-- Include aal.js - note this file doesn't exist in the 'web' directory -->
7-
<script type="text/javascript" src="/aal.js"></script>
8-
<script type="text/javascript">
9-
10-
aal.expose(say_hello_js); // Expose this function to Python
3+
4+
<head>
5+
<title>Hello, World!</title>
6+
7+
<!-- Include paling.js - note this file doesn't exist in the 'web' directory -->
8+
<script type="text/javascript" src="/paling.js"></script>
9+
<script type="text/javascript">
10+
11+
paling.expose(say_hello_js); // Expose this function to Python
1112
function say_hello_js(x) {
1213
console.log("Hello from " + x);
1314
}
14-
15+
1516
say_hello_js("Javascript World!");
16-
aal.say_hello_py("Javascript World!"); // Call a Python function
17-
18-
</script>
19-
</head>
20-
21-
<body>
22-
Hello, World!
23-
</body>
17+
paling.say_hello_py("Javascript World!"); // Call a Python function
18+
19+
</script>
20+
</head>
21+
22+
<body>
23+
Hello, World!
24+
</body>
25+
2426
</html>

0 commit comments

Comments
 (0)