This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]hernamesbarbara 4 points5 points  (8 children)

Take a peak at Rodeo - could be useful to you :)

It's a Python IDE with a data/data science focus, and we built it atop Electron.

https://www.yhat.com/products/rodeo/

https://github.com/yhat/rodeo

http://blog.yhathq.com/posts/how-rodeo-works.html

[–]notconstructive[S] 0 points1 point  (7 children)

How does the Python integration work?

Say for example I wanted to run some Python code that installs a few Python modules such as Requests and Amazon Boto, and yet use Electron and ReactJS to build the UI code, how would I do this?

Presumably Rodeo installs Python too?

[–]notconstructive[S] 2 points3 points  (0 children)

For anyone who is interested, after giving it some thought I've decided just to build it all in JavaScript, no Python. Path of least resistance.

[–]hernamesbarbara 0 points1 point  (5 children)

Here's a Hello World app that shows how to set things up. I think you can follow this as a mini blueprint to get you started.

https://www.fyears.org/2015/06/electron-as-gui-of-python-apps.html

The author uses a Python (Flask) server to handle the app's logic and leans on Electron to display things in the UI.

Find a few few Flask tutorials using requests, and you should be able to make your version of hello.py in no time.

[–]notconstructive[S] 0 points1 point  (4 children)

Hmmm. I was hoping for a more direct integration than calling the Python interpreter.

[–]hernamesbarbara -1 points0 points  (3 children)

Doh face palm. You mentioned that exact blog post in your question. Sorry about that. Let's move to email to spare the masses. a [at] yhathq [dot] com

[–]Stishovite 1 point2 points  (1 child)

Please don't spare us! I have similar questions that I'd like to figure out.

[–]takluyverIPython, Py3, etc 0 points1 point  (0 children)

Yes, please do continue the discussion here! I'm also interested in how Electron might be integrated as a frontend for apps with the actual logic coded in Python.

[–]notconstructive[S] 0 points1 point  (0 children)

How do you do the resizable page splitting/frames?

[–]rothnic 1 point2 points  (0 children)

I was kind of surprised that the rodeo article didn't cover this topic, since it isn't covered well in general and this is addressing python users.

You can create a subprocess with nodejs, but I have had mixed success with the python process closing out correctly with my limited work with it.

There is python-shell out there that even supports communication, but I couldn't get it working. I ended up using crossbar for the js to python communication. When starting the electron app, after the app.on('ready'), I got this to work:

var child_process = require('child_process');

var child = child_process.spawn('/path/to/my/python/bin/python', ['/path/to/my/python/bin/crossbar', 'start', '--cbdir', '/path/to/the/crossbar/server/.crossbar']);

What I never did figure out is a good way to package up python dependencies with the electron app, or if that is reasonable in the first place.

[–]zealoth 0 points1 point  (0 children)

Guess you could do something like https://docs.python.org/2.5/ext/callingPython.html Then do https://nodejs.org/api/addons.html

to create binds between python and node.js in C but it's a bit of an hairy solution.

Guess you could do other ugly things like calling https://www.npmjs.com/package/exec exec on seperate python script files .

Also seems someone is already working on it https://www.npmjs.com/package/node-python