How can I get the progress bar to indicate progress?

I’ve managed to get a progress bar in my main window, but it just gives the barber pole effect. I would like it to actually give the user at least some vague idea of how much time is remaining to run.

I’ve looked at various sample projects and the ASKit.dictionary but i’m stumped!

tia, Jim

I use this routine to update the progress bar. Of course, update the element names to match your project. To set the progress bar to a barber pole (indeterminate progress), set the iteration to 0, otherwise use an accurate iteration and total_count to update the progress bar accordingly:

Jon


[This script was automatically tagged for color coded syntax by Script to Markup Code]

Thanks jon, but my newblieness keeps me from getting this to work. Where does the handler update_object come from?

Are there any sample projects that show how this would be integrated into a task or set of tasks?

Thanks, Jim

Um, what’s the “update_object” handler? The code I listed above is a handler that is not automatically created, you have to add it your self. To use it, call it from within your script, for instance, when a button is clicked. What you would do is in the “on clicked” handler, do something that required a repeat loop like:

Of course, again, this requires that your progress bar and label in the main window are named accordingly.

Jon


[This script was automatically tagged for color coded syntax by Script to Markup Code]

Okay… that’s confusing and doesn’t work…

It does work. You can see a variation of it in action in my demo project:

http://homepage.mac.com/jonn8/as/dist/Stop_Loop.hqx

The variation on it in this project is that the progress bar is in a separate panel window with more explicit handlers for showing, updating, and hiding the progress panel.

Jon

Thanks jonn8, but I find it hard to follow that script. I’m back for my second attempt at getting that progress bar working. I’d really like to get it figured out.

2 things I have a hard time following in your most recent example -

  1. handlers for things like ‘activated’, ‘launched’, and ‘will finish launching’ that seem to be empty. Are they just from your template and not used. If so, no offense, but since it’s a tutorial of sorts couldn’t they be removed? Or do they have a purpose?

  2. Also your use of this line in every handler
    my update_status("event handler name " & object_name)
    what is that for?

TIA, jim

That logs to the “Run Log” what’s happening during the execution of the script.

If you don’t already the “Run Log” window, choose “Show Run Log” from the Debug menu in Xcode. You should get something like this:

Hope this helps…

This is what I use:


tell window "main"
	set uses threaded animation of progress indicator "ProgressBar" to true
	start progress indicator "ProgressBar"
	set content of progress indicator "ProgressBar" to (a number out of 100)
end tell

Your window needs to be named “main” in the AppleScript section of Interface Builder, or anything else, just remember to change it in the code too. Also, the progress bar has to be named something as well. You can set the contents to any number, probably 1 at the beginning. At the points where you want to update the progress bar, just stick thin in your script:


tell window "main"
set content of progress indicator "ProgressBar" to (the number you want the progress bar to be, out of 100)
end tell

To stop the progress bar:


tell window "main"
	set uses threaded animation of progress indicator "ProgressBar" to false
	stop progress indicator "ProgressBar"
	set content of progress indicator "ProgressBar" to 0
end tell