-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoly.desktop builder.py
More file actions
73 lines (61 loc) · 1.61 KB
/
poly.desktop builder.py
File metadata and controls
73 lines (61 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
def create_electron_app(url):
# Create a directory for the Electron app
os.makedirs("electron_app")
os.chdir("electron_app")
# Create package.json file
with open("package.json", "w") as package_file:
package_file.write(f'''
{{
"name": "poly.desktop",
"version": "1.0.0",
"main": "main.js",
"scripts": {{
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
}},
"description": "poly.ai Desktop Client - By Vortex Deskware",
"author": "Vortex Deskware",
"devDependencies": {{
"electron": "^16.0.0"
}}
}}
''')
# Create main.js file
with open("main.js", "w") as main_file:
main_file.write('''
const { app, BrowserWindow } = require('electron');
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
});
win.loadURL("''' + url + '''");
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
''')
# Install Electron
os.system("npm install --save-dev electron")
print("Electron app created successfully!")
print("Run 'npm start' to launch the Electron app.")
print("Run 'npm run dist' to build the Electron app.")
def build_executable():
os.system("npm run dist")
if __name__ == "__main__":
url = input("Enter the URL for your Electron app: ")
create_electron_app(url)
build_executable()