Refresh progress bar in math

during the calculation, I would update the progress bar to notify the user of the progress of the calculation.

Unfortunately, I cannot do this, because when I call the SetPropertyValue function

ref@SetPropertyValue [{"bar", "value"}, 70]; 

value is not updated.

I get ref this way

 ref = GUIRun[mainWindow]; 
+6
wolfram-mathematica progress-bar
source share
3 answers

If Mathematica 6 or later will try to use Monitor and ProgressIndicator instead of the old GUIKit package:

 With[{count = 1000}, Monitor[Do[Pause[0.01];, {i, count}], ProgressIndicator[Dynamic[i/count]]]] 
+9
source share

This is just an extension to @ragfield's answer.

If you want to represent limited and unlimited values, you colud do something in this direction:

 Clear["Global`*"]; count = 0; inRange = 0; i = 0; sumTgt = 10^5 Monitor[ While[count < sumTgt, If[.14 < (rand = RandomReal[]) < .15, inRange++]; count += rand; ] , {{"SumTillNow", ProgressIndicator[count, {0, sumTgt} ],count}, {"InRange", ProgressIndicator[inRange, Indeterminate],inRange}} // MatrixForm ]; 

If you want to save progress indicators as an animated gif for presentations, etc., you can change it a little:

 count = 0; inRange = 0; i = 0; sumTgt = 10^4 Monitor[ While[count < sumTgt, If[.14 < (rand = RandomReal[]) < .15, inRange++]; count += rand; ] , a[++i] = Grid[ {{"SumTillNow", ProgressIndicator[count, {0, sumTgt}],count}, {"InRange", ProgressIndicator[inRange, Indeterminate],inRange + 0.}}, Frame -> All, Alignment -> {{Left, Center, Right}}, ItemSize -> {{Automatic, Automatic, 8}}]; ]; Export["c:\Anim.gif", Table[a[j]//MatrixForm, {j, i}],"DisplayDurations"->{.3}] 

and the result:

alt text

+6
source share

Failed to complete

 Needs["GUIKit`"]; 

before using GUIKit? If not your commands will not be executed, because they are unknown. If you download GUIKit after using it, do not forget that some of its characters may be obscured by characters that you accidentally determined.

+1
source share

All Articles