I want to show a progress bar for one of my Photoshop scripts. If I do work inside a button click event then I'm able to update the progress bar without any problems.
For this script, no user interaction is required. I want to: - Show the Window - Update the progress bar as work is done - Close the Window
var win = new Window("dialog{text:'Progress',bounds:[100,100,400,150],\ bar:Progressbar{bounds:[20,20,280,31] , value:0,maxvalue:100}};");
win.show();
for(...){
//do work here
//update progress
win.bar.value = ...;
}
win.close();
The problem is, win.show();
blocks until the user closes the window. I've also tried to add an onClose
handler then close the window immediately, but the window does not ever show.
Any ideas on how I could get a progress bar to work?
The window class dialog
is a MODAL dialog and requires you to close it before the execution continues.
Use the class window
to create a non-blocking window:
var win = new Window("window{text:'Progress',bounds:[100,100,400,150],bar:Progressbar{bounds:[20,20,280,31] , value:0,maxvalue:100}};");
win.show();
for(...){
//do work here
//update progress
win.bar.value = ...;
}
win.close();
However, you will run into the next problem here. Depending on what you are doing in the loop, photoshop will not update the UI fast enough to see the progress bar moving. This is where I got stuck :/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With