Monday, January 22, 2018

#1 2003-02-24 03:48:13 pm

SharkusMarkus
Member
Registered: 2003-02-24
Posts: 7

Progess indicator help required

ok, I'm thick! I'll admit it!

Can someone tell me, in very very simple terms how to get the progress indicator or the new 10.2 idicator to animate in Studio.

All I want to do is click a button,  which would animate the progress bar (in it's barber pole mode) and then the script continues to do stuff, then I get the progress bar to stop.

I've tried and failed to do this very simple thing.

Anyone fancy creating a project which has a window, a progress indicator and a button, and showing a thicko like me the code needed to click the button and have the bar animate.

I've looked at the 'debug test' script, and canablised part of it into a new project but I still can't get it to work.

Apart from this little bit, the rest of my nice complex script works, but I'd love some progress indication as otherwise it looks like it's crashed!

thanks for any help.

Offline

 

#2 2003-03-14 08:25:53 pm

General
Member
From:: Texas
Registered: 2005-08-08
Posts: 944
Website

Re: Progess indicator help required

well...

A) you have to no interface builder (not just how to put the objects on, but how to name and wire them)

B) you have to understand object orientated programming and cocoa


and supposing you know that this will help:

Applescript:


//PROPERTIES

property keepRunning : true
property prop1 : "Test property 1"
property prop2 : "Test property 2"
property prop3 : 0

//EVENTS

on clicked theObject
   if title of theObject is "Start" then

//theObject is what ever is being clicked, in this case "Start" is a button, so its really just saying if the button is clicked

       runforever()
end clicked

on will open theObject
   set prop3 to 10
end will open

//FUNCTIONS

on runforever()
   set numberTest to 1
   set stringTest to "testing"
   
   runonce()
   
   repeat while keepRunning
       tell progress indicator "Barber Pole" of window "Main" to animate
       set prop3 to prop3 + 1
       set numberTest to numberTest + 1
       
       set contents of text field "counter" of window "Main" to numberTest as string
   end repeat
end runforever

on runonce()
   set prop3 to prop3 + 1
   set prop3 to prop3 + 1
   set prop3 to prop3 + 1
   set prop3 to prop3 + 1
   
   runonceagain()
end runonce

on runonceagain()
   set prop3 to prop3 + 1
   set prop3 to prop3 + 1
   set prop3 to prop3 + 1
   set prop3 to prop3 + 1
   
   runlasttime()
end runonceagain

on runlasttime()
   set prop3 to prop3 + 1
end runlasttime

-xen


General

Offline

 

#3 2003-05-03 04:37:32 pm

Warwick Terry
Member
Registered: 2002-11-20
Posts: 3

Re: Progess indicator help required

Anyone fancy creating a project which has a window, a progress indicator and a button, and showing a thicko like me the code needed to click the button and have the bar animate.



Just noticed this post and it reminded me what I spent last weekend doing ...

The following refers to a main window "main" with "stop" and "start" buttons and a text field "filetoenter", and a second window "status" with a progress indicator (indeterminate), a "cancel" button and a text field "fileneame".

Applescript:

on clicked theObject
   set myWindow to window "status"
   if name of theObject is "start" then
       show myWindow
       start progress indicator "progress" of myWindow
       set contents of text field "filename" of myWindow to contents of text field "filetoenter" of window "main"
   else if name of theObject is "stop" then
       stop progress indicator "progress" of myWindow
       set contents of text field "filename" of myWindow to ""
   else if name of theObject is "cancel" then
       close panel myWindow
   end if
end clicked

on should quit after last window closed theObject
   return true
end should quit after last window closed

It is very basic but seems to do what you are looking for. What really impressed me was that Applescript Studio lets you manage multiple buttons located on two windows via a single on clicked handler.
PS: As will be obvious, I am VERY new to this stuff!


Warwick Terry

Offline

 

#4 2003-06-05 10:02:27 am

cglusky
Member
Registered: 2003-06-05
Posts: 5
Website

Re: Progess indicator help required

hey sharkusmarkus,

if you are going to be using the progress bar a bunch this might help:

Applescript:


--Custom handlers for starting and stopping Progress bar---------------------------------------------------------------------------
on progressBarStart()
   tell window "main"
       set uses threaded animation of progress indicator "progress" to true
       set visible of progress indicator "progress" to true
       set visible of button "stopButton" to true
       tell progress indicator "progress" to start
   end tell
end progressBarStart

on progressBarStop()
   tell window "main"
       tell progress indicator "progress" to stop
       set visible of progress indicator "progress" to false
       set visible of button "stopButton" to false
   end tell
end progressBarStop

1)this is code from workflopro, so change the names as you like
2)"stopButton" is just a button I have that allows the user to stop the event
3)I call these handlers as needed when I want to start or stop the bar

good luck


Coby
cglusky@workflopro.com
www.workflopro.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)