Photoshop脚本-更新窗口中的进度栏 [英] Photoshop Scripting - Update Progress Bar in a Window

查看:145
本文介绍了Photoshop脚本-更新窗口中的进度栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个Photoshop脚本的进度条.如果我确实在按钮单击事件中进行工作,那么我将能够更新进度栏而不会出现任何问题.

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();

问题在于,win.show();会阻塞,直到用户关闭窗口为止.我还尝试添加onClose处理程序,然后立即关闭该窗口,但是该窗口永远不会显示.

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.

关于如何使进度条正常工作的任何想法?

推荐答案

窗口类dialog是MODAL对话框,需要您在继续执行之前将其关闭.

The window class dialog is a MODAL dialog and requires you to close it before the execution continues.

使用类window创建一个非阻塞窗口:

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();

但是,您将在这里遇到下一个问题.根据您在循环中所执行的操作,photoshop将不会足够快地更新UI以查看进度条的移动.这就是我被困住的地方:/

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 :/

这篇关于Photoshop脚本-更新窗口中的进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆