Progress bar panel
aclight
[img_assist|nid=620|title=Progress bar panel|desc=|link=node|align=right|width=230|height=157]
To use the code below, you'll need to create a global variable in the root data folder named
percentFinished
and you need to update this variable in your loop. Keep the following points in mind:- If you're doing all of your processing in one loop/function that doesn't return until the process is complete, you'll need to periodically call
DoUpdate
so that Igor will redraw the progress bar control. - Again, if you're doing everything in one big loop, the Abort button on the panel may be useless, since Igor might not process the button push event until the loop has finished. The behavior here may depend on what version of Igor you're running. I used this code originally within a background task, and each time the background task function was called I processed a chunk of data, updated the percentFinished variable, and then returned until the background task was called again.
Window pnlProgress() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /W=(267,122,480,236) as "Progress"
SetDrawLayer UserBack
SetDrawEnv fsize= 16
DrawText 74,23,"Progress:"
ValDisplay valdispProgress,pos={8,28},size={200,45},frame=4
ValDisplay valdispProgress,limits={0,100,0},barmisc={10,1},bodyWidth= 200
ValDisplay valdispProgress,value= #"percentFinished"
Button buttonAbort,pos={73,78},size={70,30},proc=Button_Abort,title="Abort"
Button buttonAbort,fSize=14
End
Function Button_Abort(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
<add code here to abort the loop or process>
break
endswitch
return 0
End
PauseUpdate; Silent 1 // building window...
NewPanel /W=(267,122,480,236) as "Progress"
SetDrawLayer UserBack
SetDrawEnv fsize= 16
DrawText 74,23,"Progress:"
ValDisplay valdispProgress,pos={8,28},size={200,45},frame=4
ValDisplay valdispProgress,limits={0,100,0},barmisc={10,1},bodyWidth= 200
ValDisplay valdispProgress,value= #"percentFinished"
Button buttonAbort,pos={73,78},size={70,30},proc=Button_Abort,title="Abort"
Button buttonAbort,fSize=14
End
Function Button_Abort(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
<add code here to abort the loop or process>
break
endswitch
return 0
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
Cool!
Would a better reference to the control variable be ...
... in case processing is done outside root. Also, by changing to NewPanel/N=pnl_Panel/W=..., this part could be added (running as a background task?) to automatically kill the panel ...
NVAR pc = root:percentFinished
if (pc>=100)
KillPanel pnl_Panel
<do other things when processing is done>
endif
return 0
end
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 24, 2008 at 03:02 pm - Permalink
I played around with the parameters, but the white bar always has the same height - which is too big for my application....
June 16, 2014 at 10:20 am - Permalink
June 17, 2014 at 04:00 am - Permalink
October 18, 2017 at 01:58 am - Permalink
Displayhelptopic "Progress Windows"
for the official documentation.October 18, 2017 at 05:32 am - Permalink