forked from ByeongGil-Jung/2018-Jaram-Summer-Workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
64 lines (50 loc) · 1.63 KB
/
main.js
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
'use strict';
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
// Keep a global reference of the mainWindowdow object, if you don't, the mainWindowdow will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
var subpy = null;
// This method will be called when Electron has finished
// initialization and is ready to create browser mainWindow.
// Some APIs can only be used after this event occurs.
app.on('ready', function() {
// spawn server
subpy = require('child_process').spawn('python', ['controller.py']);
// Create the browser mainWindow
mainWindow = new BrowserWindow({
width: 800,
height: 600,
// transparent: true, // transparent header bar
// fullscreen: true,
// opacity:0.8,
// darkTheme: true,
// frame: false,
resizeable: true
});
mainWindow.webContents.openDevTools();
// Load the index page
mainWindow.loadURL('http://localhost:8011/');
// Open the DevTools.
//mainWindow.webContents.openDevTools();
// Emitted when the mainWindow is closed.
mainWindow.on('closed', function() {
// Dereference the mainWindow object
mainWindow = null;
});
});
// disable menu
electron.app.on('browser-window-created',function(e,window) {
window.setMenu(null);
});
// ------- app terminated
app.on('window-all-closed', function() {
// quit app if windows are closed
app.quit();
});
app.on('quit', function() {
// kill the python server on exit
subpy.kill('SIGINT');
});