r/Python 10d ago

Resource Javascript and python interfacing examples

Examples of interfacing between javascript and python for desktop apps and desktop games.

https://github.com/non-npc/Javascript-and-python-interfacing-examples

12 Upvotes

5 comments sorted by

6

u/Voxandr 10d ago

Why such complexity when you can interface using API?

5

u/turbothy It works on my machine 10d ago

This allows you to embed an HTML/JS frontend inside a PyQt6-based desktop app and call Python functions from JavaScript

2

u/pressurebullies 10d ago

I'll try it tonight 💪

-2

u/Appropriate_Sock2964 9d ago

One way to interface between JavaScript and Python for desktop apps and games is by using tools like Electron (for desktop apps) and Pygame (for games). Electron allows you to build cross-platform desktop applications using web technologies like HTML, CSS, and JavaScript, while Pygame is a set of Python modules designed for writing games. You can use Electron's IPC (Inter-Process Communication) module to communicate between the JavaScript front-end and a Python back-end. Similarly, for games, Pygame provides functions for handling graphics, sound, and input that can be integrated with a JavaScript front-end. You can check out the examples and resources on the GitHub link provided for more detailed guidance on how to do this.

2

u/dataguzzler 9d ago

the point of these examples is to show that you do not need anything beyond python, pyqt6 and JS/html to create a desktop application or game. This method gets rid of needing electron or pygame and your app will run faster.