Progress Bar
Progress Bar
Recently just added on of these to a script. I found a couple of examples over at Adobe forums. A couple of which are quoted as and appear broken as of a CS4 update. Found one by xbytor that still does work (no surprise there) Question is do I have to 'hide and re-show' the window in order to update the progress? While processing larger files it's not so jittery but it is when dealing with lots of smaller files… Is this a known problem and a work around or should this window be smooth…? TVM
Progress Bar
I've changed the code for this a bit. update() show() appears to work pretty well in CS5. Not sure about earlier versions.
The show()/hide()/show() bit was necessary in older versions.
Code: Select all win.updateProgress = function(val) {
var win = this;
if (val != undefined) {
win.bar.value = val;
}
// else {
// win.bar.value++;
// }
if (win.recenter) {
win.center(win.parentWin);
}
win.update();
win.show();
// win.hide();
// win.show();
};
The show()/hide()/show() bit was necessary in older versions.
Code: Select all win.updateProgress = function(val) {
var win = this;
if (val != undefined) {
win.bar.value = val;
}
// else {
// win.bar.value++;
// }
if (win.recenter) {
win.center(win.parentWin);
}
win.update();
win.show();
// win.hide();
// win.show();
};
Progress Bar
Thanks X, I will give that a try and see if I can smooth it out… I had not yet got around to seeing if I get an update via any other routes… I can test the file length and for the small stuff slow things down a little just so the users can see the progress. The bigger files slow it enough themselves…
Progress Bar
Hum, I now get a nice smooth constant window where the text string in the main palette window updates correctly but the progress bar itself does not increment…? I've tried a couple of options even using window.layout.layout(); No success yet I'll keep trying…
Edit… I've added a sample script by Marc Autret from the ID forum that I've since done some experimenting with… If it helps… In my script real I update the w.st text which is working fine…
Code: Select allvar progressBar = function(/*str*/title) {
var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
st.justify = 'center';
w.center();
this.reset = function( msg,maxValue ) {
st.text = msg;
pb.value = 0;
pb.maxvalue = maxValue||0;
pb.visible = !!maxValue;
w.show();
};
this.hit = function() { ++pb.value; };
this.hide = function() { w.hide(); };
this.close = function() { w.close(); };
this.show = function() { w.show(); };
this.update = function() { w.update(); };
this.layout = function() { w.layout.layout(); };
};
//------------------------------------------------
// SAMPLE CODE
//------------------------------------------------
function main() {
var pBar = new progressBar("Script Title");
pBar.reset("Processing Routine #1...", 10);
for ( var i = 0 ; i < 10; ++i ) {
pBar.hit();
//pBar.hide();
//pBar.show();
pBar.update();
pBar.layout();
$.sleep(250);
};
pBar.reset("Processing Routine #2...", 10);
for ( var i = 0 ; i < 10; ++i ) {
pBar.hit();
pBar.hide();
pBar.show();
$.sleep(250);
};
pBar.close();
};
main();
Edit… I've added a sample script by Marc Autret from the ID forum that I've since done some experimenting with… If it helps… In my script real I update the w.st text which is working fine…
Code: Select allvar progressBar = function(/*str*/title) {
var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
st.justify = 'center';
w.center();
this.reset = function( msg,maxValue ) {
st.text = msg;
pb.value = 0;
pb.maxvalue = maxValue||0;
pb.visible = !!maxValue;
w.show();
};
this.hit = function() { ++pb.value; };
this.hide = function() { w.hide(); };
this.close = function() { w.close(); };
this.show = function() { w.show(); };
this.update = function() { w.update(); };
this.layout = function() { w.layout.layout(); };
};
//------------------------------------------------
// SAMPLE CODE
//------------------------------------------------
function main() {
var pBar = new progressBar("Script Title");
pBar.reset("Processing Routine #1...", 10);
for ( var i = 0 ; i < 10; ++i ) {
pBar.hit();
//pBar.hide();
//pBar.show();
pBar.update();
pBar.layout();
$.sleep(250);
};
pBar.reset("Processing Routine #2...", 10);
for ( var i = 0 ; i < 10; ++i ) {
pBar.hit();
pBar.hide();
pBar.show();
$.sleep(250);
};
pBar.close();
};
main();
Progress Bar
Okay, i know this is a very very old post. But my question remains:
The progress bar does not work for me. Is does not show any progress... (ps 12.1)
Any thoughts?
The progress bar does not work for me. Is does not show any progress... (ps 12.1)
Any thoughts?
Progress Bar
I just did a quick test with CSX in PS/CC and the progress bar works fine which leads me to believe that it works fine for all versions back to CS4 or so. The code in CSX is basically what I posted in the thread above but you may want to look into the CSX source for more details.