a fast and simple micro-framework for small browser-based application
Project description
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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
eui-1.1.2.tar.gz
(6.3 kB
view details)
Built Distribution
eui-1.1.2-py3.8.egg
(13.0 kB
view details)
File details
Details for the file eui-1.1.2.tar.gz
.
File metadata
- Download URL: eui-1.1.2.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dedf01ee3c0c88ca9c714df91c7feffea0e2961b6aa90603d337445e95c740f6 |
|
MD5 | 388e695ccb26816412376fb2b7cba6ce |
|
BLAKE2b-256 | a8715f8b2679f75e02f0353a839bcef8dd0e89a1769a68df864d240a4e60ff22 |
File details
Details for the file eui-1.1.2-py3.8.egg
.
File metadata
- Download URL: eui-1.1.2-py3.8.egg
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00395f54eea943e26472f08c60a8c61238c07a5d2ff6a022b26d16f61570efb1 |
|
MD5 | 9456dd44504dc5f1c06348c2dc4d3c76 |
|
BLAKE2b-256 | 9650e9c05692524f052704d853a9e9b652b6282349c5a1ec88d5247c22e68b09 |