during the computation I would update the value of progress bar to notify to the user the progress of the computation.
Unfortunately I'm not able to do this because when I call SetPropertyValue function
ref@SetPropertyValue[{"bar", "value"}, 70];
the value isn't updated.
I obtain ref in this way
ref = GUIRun[mainWindow];
With Mathematica 6 or later try using Monitor and ProgressIndicator instead of the older GUIKit package:
With[{count = 1000},
Monitor[Do[Pause[0.01];, {i, count}],
ProgressIndicator[Dynamic[i/count]]]]
This is just an extension to @ragfield's answer.
If you want to represent bounded and unbounded magnitudes, you colud do something along these lines:
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 the progress indicators as an animated gif for presententations and the such, you could modify it a bit:
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 is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With