Eel
https://github.com/ChrisKnott/Eel
pip install eel
import eel
eel.init('web')
eel.start('main.html')
<script type="text/javascript" src="/eel.js"></script>
js 调用 python
python
@eel.expose
def my_python_function(a, b):
print(a, b, a + b)
js
eel.my_python_function(1, 2);
python 调用 js
js
eel.expose(my_javascript_function);
function my_javascript_function(a, b, c, d) {
if (a < b) {
console.log(c * d);
}
}
python
eel.my_javascript_function(1, 2, 3, 4)