Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const electron = require('electron');
- const url = require('url');
- const path = require('path');
- const {app , BrowserWindow , Menu} = electron;
- let mainWindow;
- let addWindow;
- //Listen for the app to be ready
- app.on('ready' , function(){
- //Create new window
- mainWindow = new BrowserWindow({});
- //Load HTML file into the main window
- mainWindow.loadURL(url.format({
- pathname: path.join(__dirname , 'mainWindow.html'),
- protocol: 'file:',
- slashes:true
- }));
- //Build menu from template
- const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
- //Insert the menu
- Menu.setApplicationMenu(mainMenu);
- });
- //Handle CreateAddWindow function
- function CreateAddWindow()
- {
- //Create new window
- addWindow = new BrowserWindow
- ({
- width: 200,
- height: 300,
- title: 'Add to shopping list'
- });
- //Load HTML file into the main window
- addWindow.loadURL(url.format({
- pathname: path.join(__dirname , 'addWindow.html'),
- protocol: 'file:',
- slashes:true
- }));
- }
- const mainMenuTemplate =
- [
- {
- label:'File',
- submenu:
- [
- {
- label:'Add Item',
- CreateAddWindow()
- },
- {
- label: 'Clear Items'
- },
- {
- label:'Quit',
- accelerator: process.platform == 'darwin' ? 'Command+Q' : 'Ctrl+Q',
- click()
- {
- app.quit();
- }
- }
- ]
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement