I usually process data such as follows:
Module[
{vars},
...
Map[
Composition[
h,
g,
f]
]@lst
...
]
For some lists which can take quite a long time to process I want to show a progress indicator.
Dynamic[ProgressIndicator[$progress/$total]]
where
$progress = listitem currently being processed;
$total = length of list
both
$progress, $total
are global variables.
The issue is about how to implement progress indicators with as minimal change to the current programs as possible.
I was thinking of implementing the following 'standard'function for progress update:
p[]:=$progress++
this function can then be composed as last function of the current function compositions.
In each module initialize
$progress = 1
$total = Length[lst]
Finally, add p[] to the composition.
Rapping up:
Dynamic[ProgressIndicator[$progress/$total]]
Module[
{$progress=1,$total=Length[lst]},
...
Map[
Composition[
p,
h,
g,
f]
]@lst
...
]
This method works but is not ideal. I haven't succeeded in getting this to work in a Manipulate Panel. I usually select lists and other parameters in a Manipulate program and start a processing module with an action Button, ideally I would like to see the progress in the Manipulate panel.
Questions: how can I implement a progress indicator construct which would work on a Manipulate panel?
Note that both the module and the Manipulate functions are members of a package, i.e.:
processRows[]
shows a Manipulate in the Notebook of the package user with several controls to select data and buttons to start the processing. I don't want to change this. The only additional requirement is the additional display of a progress indicator of some kind.
p
be definedp[x_] := ($progress++; x)
instead? $\endgroup$ – Mr.Wizard Mar 7 '17 at 8:59