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 SetPropertyVal开发者_如何学Cue 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:
Did you remember to execute
Needs["GUIKit`"];
before starting to use the GUIKit ? If not your commands won't execute, because they are not known. If you load the GUIKit after you start using it, don't forget that some of its symbols may be shadowed by the symbols you have inadvertently defined.
精彩评论