Comments (5)
Worked it out, wasnt reading properly
from electron-progressbar.
Hi there!
I've just created an example for you with buttons to show/hide the progressbar.
In case you can't make it work, please paste your code here so I can take a look.
main.js:
const {app, BrowserWindow, ipcMain} = require('electron');
const ProgressBar = require('electron-progressbar');
let mainWindow;
let progressBar;
function loadApp () {
mainWindow = new BrowserWindow({
width : 300,
height : 200
});
mainWindow.loadURL(`file://${__dirname}/test_page.html`);
};
function showProgressbar () {
if (progressBar) {
return;
}
progressBar = new ProgressBar({
text: 'Preparing data...',
detail: 'Wait...'
});
progressBar
.on('completed', function() {
progressBar.detail = 'Task completed. Exiting...';
progressBar = null;
});
// launch the task...
// launchTask();
}
function setProgressbarCompleted () {
if (progressBar) {
progressBar.setCompleted();
}
}
function init () {
loadApp();
ipcMain.on('show-progressbar', showProgressbar);
ipcMain.on('set-progressbar-completed', setProgressbarCompleted);
}
app.on("ready", init);
test_page.html:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<div style="text-align:center">
Test page<br><br>
<button id="show-progressbar">Show progressbar</button><br><br>
<button id="set-progressbar-completed">Set progressbar completed</button>
</div>
<script>
const ipc = require('electron').ipcRenderer;
document.querySelector('#show-progressbar').addEventListener('click', function(){
ipc.send('show-progressbar');
});
document.querySelector('#set-progressbar-completed').addEventListener('click', function(){
ipc.send('set-progressbar-completed');
});
</script>
</body>
</html>
from electron-progressbar.
Thank you so much. Got it working.
I have changed it so I can pass in a maxValue, which works, but then I added another function to update the progress, as in my button on click it loops around processing some images, I want to update the progress bar when each one is complete, currently it just pops up and says Wait... as per the setup and then disappears when the loop is done.
Any ideas?
from electron-progressbar.
You can pass multiple parameters to the send function:
ipc.send('set-progressbar-value', {value:9});
And then you can set the progress bar's value like this (inside your "main.js", for example):
progressBar.value = x;
from electron-progressbar.
Glad you got it working! =)
from electron-progressbar.
Related Issues (20)
- Progress bar not showing up HOT 6
- How to use remote BrowserWindow HOT 2
- Progress bar not showing but getting require is not defined HOT 3
- How can I customize the progress bar css? HOT 1
- App Icon Progress Bar Doesn't Reset On Abort HOT 1
- Using with Electron-updater HOT 5
- Invalid call: trying to set value but the progress bar window is not active. HOT 5
- When text set Asia character show two arrow. HOT 2
- Progress bar details not being displayed other than window title HOT 9
- It does not work properly with Electron 12 HOT 2
- Closing progressBar window does not clear application progress bar
- Multi progressbar UI for queued process
- It does not work in TypeScript HOT 1
- Progressbar is working fine before creating exe of app ,after exe generated it seems blank HOT 2
- How to load image in electron-progressbar? HOT 3
- Whole Script stops after bar is completed HOT 3
- How to implement progress bar for electron auto updater download progress HOT 5
- Cannot read properties of null (reading 'classList') HOT 1
- hide or show progressbar window HOT 4
- Progress-bar not show in electron-vue HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-progressbar.