-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
53 lines (44 loc) · 1.27 KB
/
Copy pathmain.js
File metadata and controls
53 lines (44 loc) · 1.27 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
const { app, BrowserWindow, ipcMain } = require('electron');
const { spawn } = require('child_process');
const path = require('path');
let win;
let pythonServer;
function createWindow() {
win = new BrowserWindow({
width: 400,
height: 400,
minWidth: 300,
minHeight: 300,
transparent: true,
frame: false,
backgroundColor: '#00000000',
alwaysOnTop: true,
hasShadow: true,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false,
},
});
// win.setBackgroundMaterial('acrylic'); // Disabled to increase transparency/see-through effect
win.loadFile('index.html');
}
function startPythonServer() {
pythonServer = spawn('python', [path.join(__dirname, 'server.py')], {
stdio: 'pipe',
});
pythonServer.stdout.on('data', (d) => process.stdout.write(d));
pythonServer.stderr.on('data', (d) => process.stderr.write(d));
}
app.whenReady().then(() => {
startPythonServer();
// Give Flask a moment to start
setTimeout(createWindow, 1500);
});
app.on('window-all-closed', () => {
if (pythonServer) pythonServer.kill();
app.quit();
});
// IPC handlers for window controls
ipcMain.on('minimize', () => win?.minimize());
ipcMain.on('close', () => win?.close());