News for hackers. Stuff that matters.
Re:The Game UI Database, a comprehensive reference of game i... by klenwell on Saturday December 05, 2020 @02:44PM (#25317645)
> I'm building the UI using ElectronJS and Svelte, whilst the backend is a separate Python project.

Thanks for sharing this. I have a relatively simple Python script that I'm trying to package for a non-technical Windows user so, as someone whose experience skews toward web development, your comment caught my attention.

I just googled "electron svelte python" and found this write up:

https://medium.com/@abulka/electron-python-4e8c807bfa5e

Which references this Github repo:

https://github.com/fyears/electron-python-example

It all sounds pretty brittle. How are you managing communication between your ElectronJS frontend and Python backend? Any references you recommend?

Re:The Game UI Database, a comprehensive reference of game i... by petargyurov on Saturday December 05, 2020 @03:02PM (#25317784)
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

Re:The Game UI Database, a comprehensive reference of game i... by vlovich123 on Saturday December 05, 2020 @08:39PM (#25320166)
Why not use something like gRPC or cap’n’proto to make the request/response stuff easier to manage?
Re:The Game UI Database, a comprehensive reference of game i... by Aeolun on Sunday December 06, 2020 @06:53AM (#25322943)
Because it still requires request and response. The way you are doing request/response, or encoding the data is immaterial.
Re:The Game UI Database, a comprehensive reference of game i... by sususu on Saturday December 05, 2020 @06:04PM (#25319299)
Some time ago I helped build a software that heavily used some python GIS libraries (GDAL, rasterio, etc) and we needed a UI for some windows users. We chose cefpython[1] to the job, as we could interface easily between the python and JS parts. The development experience is not so polished as of Electron though.

Nonetheless, is a great project and not so difficult to use, although not perfect, it worked perfectly for our needs.

[1] https://github.com/cztomczak/cefpython

Re:The Game UI Database, a comprehensive reference of game i... by hcrad on Saturday December 05, 2020 @05:19PM (#25318952)
As far as quickly standing up an effective gui for python, I'd recommend gooey.

https://github.com/chriskiehl/Gooey