Examples of interfacing between javascript and python for desktop apps and games without requiring a localhost server component.
You can achieve the same functionality as eel or Electron by using PyQt6's QWebEngineView in combination with QWebChannel to create a bridge between Python and JavaScript.
This allows you to embed an HTML/JS frontend inside a PyQt6-based desktop app and call Python functions from JavaScript (and vice versa).
QWebEngineView: A browser component inside PyQt6 that can render HTML, CSS, and JavaScript.
pip install PyQt6-WebEngine
QWebChannel: A communication bridge that lets JavaScript call Python functions directly.
qwebchannel.js is available here
Python acts as the backend, while HTML/JavaScript provide the frontend.
main.py will load multi-threading_demo.html by default.
To try the other demos, simply replace that line 160 in main.py with the name of the desired demo file you wish to see.
- Echo Demo
- takes the input and sends it to python then back to javascript
- Multi-Threading Demo
- each click creates a task that runs for the input number of seconds in parallel with other running tasks
- Data Processing Demo
- takes the input and send it to python where it is validated or denied then sent back to javascript
Uses the pixel.js coin collector game demo, with added save/load game state functionality.
Demonstrates how to use the qwebchannel bridge to send save/load messages and data to python for processing.
The assets are from the pixel.js coin collector demo (https://github.com/rastating/pixel.js)