Is it possible to show a fixed text such as "updating..." instead of the last result shown, when Manipulate
is re-evaluating an expression (in a slow evaluation context)? How to do it?
More precisely, I have a Button
element in the set of controls, and it is the action triggered by the button the one that slows down the process, and not the results shown in the Manipulate
sentence themselves.
This could be a MWE for what I mean:
Manipulate[result,
{{x, 5}, 0, 10, 1, Appearance -> {"Labeled"}, AppearanceElements -> None},
{{y, 5}, 0, 10, 1, Appearance -> {"Labeled"}, AppearanceElements -> None},
Button["Calculate", Pause[2]; result = x + y],
TrackedSymbols :> {result},
Initialization -> Clear[result, x, y]]
In this example, the values for two integer numbers x
and y
are selected using their respective slider controls, and then a button is used to perform some calculations based on them. Finally, results based on those calculations are shown using Manipulate
.
So, regarding this example, my question is: how can I show the text "updating..." while the button is thinking?
If you think there would be an easier solution in case it was not the button but the expression to be shown by Manipulate
the one that takes some long time to be executed, I think I could also modify my real problem to be like that. The MWE could be like this:
Manipulate[Pause[2]; parameters[[1]] + parameters[[2]],
{{a, 5}, 0, 10, 1, Appearance -> {"Labeled"}, AppearanceElements -> None},
{{b, 5}, 0, 10, 1, Appearance -> {"Labeled"}, AppearanceElements -> None},
Button["Calculate", parameters = {a, b}],
TrackedSymbols :> {parameters},
Initialization -> (Clear[a, b, parameters]; parameters = {5, 5})]
It would be also OK if the text "updating..." appeared in the button, temporarily replacing the "Calculate" text. It would be a little bit strange, but also valid.
I look forward to your solutions.