Re: ProgressIndicator inside DynamicModule
- To: mathgroup at smc.vnet.net
- Subject: [mg109835] Re: ProgressIndicator inside DynamicModule
- From: István Zachar <replicatorzed at gmail.com>
- Date: Wed, 19 May 2010 20:12:30 -0400 (EDT)
Dear Patrick,
Thanks for the help, but the problem is not solved.
First of all, I did not state the problem is in the ProgressIndicator. I
rather suggested that DynamicModule is the cause of 'misfunctioning'.
Furthermore, your solution does not solve anything. My toy model
represented a more complex situation, where I have an iterative function
(a modified NDSolve, represented here with the Do loop), for which I
want to check on the progress via a similar construct as StepMonitor.
Thus you have thrown out the baby with the water by just retaining pr++.
If I rewrite your version to mirror my issue, I end up with something
like this:
DynamicModule[{pr = 0, range = {0, 100}, sw = False}, Grid@{{
Button["Push me", sw = Not[sw]; pr = 0;],
Dynamic@ProgressIndicator[Dynamic@pr, range],
Dynamic@If[sw, Do[Pause[0.02]; pr = i, {i, range[[1]],
range[[2]]}]; pr],
Dynamic@Switch[sw, True, "Calculating...", False, "Finished."]
}}]
which AGAIN won't produce the correct behaviour for ProgressIndicator.
Any other idea?
On 2010.05.19. 14:04, Patrick Scheibe wrote:
Hi,
the problem is *not* the progress indicator but your button!
The button-function does not update dynamically the values.
What about:
DynamicModule[{pr = 0, range = {0, 100}, sw = False}, Grid@{
{Button["Push me", sw = Not[sw]],
Dynamic@ProgressIndicator[Dynamic@pr, range],
Dynamic@If[sw && pr < Last@range, Pause[0.02]; pr++, pr],
Dynamic@
Switch[sw, True, "Calculating...", False, "Finished.", _,
"Standing by."]}}]
Cheers
Patrick