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

Startup Dependencies with Python #3572

Open
abhi-arya1 opened this issue Dec 31, 2023 · 0 comments
Open

Startup Dependencies with Python #3572

abhi-arya1 opened this issue Dec 31, 2023 · 0 comments
Labels

Comments

@abhi-arya1
Copy link

abhi-arya1 commented Dec 31, 2023

How would I go about adding a startup function (a Python script to be exact) that runs when the app is launched? I've added a function to main.ts in src to do this (below), but it hasn't responded and just runs the createWindow() function. The only time it worked was when I added the python3 [path to script] to npm start but this doesn't worked when the app is packaged. I have not edited anything further than main.ts besides the npm start script in package.json above (which was removed)
Any help would be appreciated as the Python script is a tkinter module that populates a necessary json file. Additionally, this has to be a cross-platform application, so I can't use Pyinstaller to create .exe files.
Thanks!

app.whenReady()
    .then(() => {
        runPythonScript(); // does this via the execSync() method from 'child-process'
        createWindow();
        app.on('activate', () => {
            if (mainWindow === null) createWindow();
        });
    })
    .catch(console.log);

My python script at the moment for testing is just this:

import tkinter

if __name__ == "__main__":
    window = tkinter.Tk()
    window.mainloop()
@abhi-arya1 abhi-arya1 changed the title Startup Dependencies Startup Dependencies with Python Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant