Skip to content

Commit

Permalink
Made a Simple GUI using Electron and Tried Making a GUI using Nana an…
Browse files Browse the repository at this point in the history
…d ImGui
  • Loading branch information
Sh0g0-1758 committed Nov 9, 2023
1 parent 0e32ada commit df22a3e
Show file tree
Hide file tree
Showing 120 changed files with 19,876 additions and 0 deletions.
1 change: 1 addition & 0 deletions GUI/Electron/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions GUI/Electron/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
Title: <input id="title"/>
<button id="btn" type="button">Set</button>
<script src="./renderer.js"></script>
</body>
</html>
62 changes: 62 additions & 0 deletions GUI/Electron/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('node:path')

function createWindow () {
const mainWindow = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})

ipcMain.on('set-title', (event, title) => {
const webContents = event.sender
const win = BrowserWindow.fromWebContents(webContents)
win.setTitle(title)
})

mainWindow.loadFile('index.html')
}

app.whenReady().then(() => {
createWindow()

app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})

app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})


// const { app, BrowserWindow, ipcMain, dialog } = require('electron')
// const path = require('node:path')

// async function handleFileOpen() {
// const { canceled, filePaths } = await dialog.showOpenDialog()
// if (!canceled) {
// return filePaths[0]
// }
// }

// function createWindow() {
// const mainWindow = new BrowserWindow({
// webPreferences: {
// preload: path.join(__dirname, 'preload.js')
// }
// })
// mainWindow.loadFile('index.html')
// }

// app.whenReady().then(() => {
// ipcMain.handle('dialog:openFile', handleFileOpen)
// createWindow()
// app.on('activate', function () {
// if (BrowserWindow.getAllWindows().length === 0) createWindow()
// })
// })

// app.on('window-all-closed', function () {
// if (process.platform !== 'darwin') app.quit()
// })
Loading

0 comments on commit df22a3e

Please sign in to comment.