Skip to content

StupiDeity/electron-python-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

electron-python-package

Clone and run for a quick way to see Electron in action with Python.

A basic Electron application needs just these files:

  • package.json - Points to the app's main file and lists its details and dependencies.
  • main.js - Starts the app and creates a browser window to render HTML. This is the app's main process.
  • index.html - A web page to render. This is the app's renderer process.

You can learn more about each of these components within the Quick Start Guide.

To Use

To clone and run this repository you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

# Clone this repository
git clone https://github.com/stupideity/electron-python-package
# Go into the repository
cd electron-python-package
# Install node dependencies
npm install
# Setup virtual environment
cd matmul
# Initialise the environment
virtualenv venv
# Activate the environment
. venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt

# Run the app
electron .

What's Happening

  1. Electron will look for the python code in matmul directory
  2. It will spawn a separate process to launch the python script (matmul/api.py)
  3. The python code will launch a Flask server and listen on http:https://127.0.0.1:5000/matrix/multiply
  4. The API endpoint will accept a POST request of the form:
    1. {"arr1":[[1,2],[3,4]],"arr2":[[5,6],[7,8]]}
  5. Electron will start up and display the 2D arrays along with a button for Multiply (main.js)
  6. Clicking the Multiply button will launch a HTTP REST call to the python API endpoint and retrieve the results (renderer.js)
  7. These results are then dumped to the #results div (index.html)

License

CC0 1.0 (Public Domain)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published