Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think I came across that as well. I didn't like it.

As far as I understand, there are two ways to handle communication between the Python and ElectronJS:

1) Use inter-process communication. Basically, your Python app outputs to stdin and your Electron app consumes the output. Also works the other way. This is what I went with.

2) Use a Flask (or equivalent) local web server and have your app send requests to it.

I find method 2) a bit hacky and unintuitive for a desktop app. If you are planning on hosting your backend in the cloud this would be a decent solution, but I am not.

I had already done some work to turn my Python app into a standalone CLI tool using `click` [0] which made the interaction with ElectronJS very simple. I used `python-shell` [1] for the inter-process communication. I do think that I might not need this once I package my Python app into an .exe -- then Electron should be able to interact with it in some way without caring that it's built in Python.

You can take a look at my repo here, though it's still in its infancy: https://github.com/petargyurov/megadetector-gui

[0] https://click.palletsprojects.com/en/7.x/

[1] https://www.npmjs.com/package/python-shell



Why not use something like gRPC or cap’n’proto to make the request/response stuff easier to manage?


Because it still requires request and response. The way you are doing request/response, or encoding the data is immaterial.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: