Reputation: 6811
After developing a Python CLI app, I realized that it's time for it to have an Electron frontend.
How can the Electron app communicate with the Python app in response to a user action on the UI?
Update: Is it typical for the Python CLI app to be converted into a long-running server using like asyncio
, and is Kafka for IPC an overkill?
Upvotes: 0
Views: 669
Reputation: 921
It depends, but in general it should be possible to use the existing CLI for IPC. You can spawn the CLI app as a subprocess from Electron and communicate with it through standard text streams. Of course, this method is simplistic and works properly only if GUI "owns" a CLI instance and CLI does't need to live longer than the GUI. Also, things become more complicated if either app must be a singleton (e.g. a second GUI instance must connect to the same one CLI instance). In such cases, a server makes sense.
Upvotes: 1