Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Electron + CreateReactApp Eexample #696

Closed
wants to merge 9 commits into from

Conversation

daniel-carvajal
Copy link

@daniel-carvajal daniel-carvajal commented Jul 4, 2023

Should close #216, #57, #428
Relates to #285, #544, #266, #607, #159, #491

  • Only configured for MacOS at the moment. Added a build.sh file for convenience.
  • To test: first do npm install, then run ./build.sh, or follow instructions in README.md.
  • If needed, modify download_electron.sh to get Electron version for your chip (Intel or ARM).

Also somewhat followed this article as reference to configure CRA app with Electron.

@daniel-carvajal
Copy link
Author

Attempting to work out issue related to process not terminating properly on Electron window close, will reopen then.

…option to include modified package.json in build folder using . Included to facilitate build process.
@daniel-carvajal
Copy link
Author

Python app terminates correctly now when Electron is closed, using:

in main.js

  mainWindow.on("close", function (e) {
    if (mainWindow) {
      mainWindow.webContents.send("app-close");
    }
  });

in App.tsx

  componentDidMount() {
   ipcRenderer.on('app-close', () => {
     eel.quit_app()
   });
  }

and in eel_electron_CRA.py

@eel.expose
def quit_app():
    """Quit the app."""
    print('Exiting python app') 
    os._exit(0)

---onefile --noconsole flags needs to be further tested though.

@daniel-carvajal
Copy link
Author

Currently main.js uses this configuration (may need improvements) as discussed here:

webPreferences: {
  preload: path.join(__dirname, 'preload.js'),
  contextIsolation: false,
  nodeIntegration: true,
  nodeIntegrationInWorker: true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example using Electron and React
1 participant