eui
eui means easy UI. It is a fast and simple micro-framework for small browser-based applications. Python and JS communicate through websocket protocol.
install
pip install eui
example
Step 1:
create python file, main.py:
import webbrowser
import eui
def say_hello(message):
print('receive message from js:', message)
eui.js('''
(msg) => {
alert('receive message from py: ' + msg)
}
''', message)
def startup_callback():
webbrowser.open(f'http://localhost:{eui.get_port()}/static/index.html')
handlers = {
'say_hello': say_hello,
'exit': eui.exit
}
eui.start(handlers=handlers, callback=startup_callback)
Step 2:
create UI file index.html in static folder:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>eui test</title>
<script src="eui.js"></script>
<script type="text/javascript">
function sendMessage() {
var message = document.getElementById('message').value;
eui.py('say_hello', message);
}
</script>
</head>
<body>
<input id="message">
<button onclick="sendMessage()">Send</button>
</body>
</html>
Step 3:
run main.py
snapshot:
Release files for eui 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eui-1.1.2.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eui-1.1.2-py3.8.egg | Legacy Egg format | - | - | Details |
Total release size: 19.3 kB
Release files / eui-1.1.2.tar.gz
| Download URL | eui-1.1.2.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dedf01ee3c0c88ca9c714df91c7feffea0e2961b6aa90603d337445e95c740f6
|
|
BLAKE2b-256 checksum How to use checksums |
a8715f8b2679f75e02f0353a839bcef8dd0e89a1769a68df864d240a4e60ff22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2
|
Release files / eui-1.1.2-py3.8.egg
| Download URL | eui-1.1.2-py3.8.egg |
|---|---|
| Size | 13.0 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
00395f54eea943e26472f08c60a8c61238c07a5d2ff6a022b26d16f61570efb1
|
|
BLAKE2b-256 checksum How to use checksums |
9650e9c05692524f052704d853a9e9b652b6282349c5a1ec88d5247c22e68b09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2
|