3
$\begingroup$

I frequently use SynchronousInitialization -> False when I have time consuming initialization in a Manipulate expression. I was wondering how I could change the label "Evaluating Initialization..." to, say, "Wait please..."?

Manipulate[x, 
 {x, 0, 1}, 
 SynchronousInitialization -> False, 
 Initialization :> (Pause[1])]

enter image description here

$\endgroup$
1
  • $\begingroup$ I do not see an option in SynchronousInitialization to change this. may be you could send WRI a feature request to add such option to change the message. $\endgroup$
    – Nasser
    Nov 9, 2017 at 1:58

1 Answer 1

2
$\begingroup$

not recommended approach

With Method -> {"TemplateExpand" -> True} you can inspect whole structure of created boxes.

ToBoxes[Manipulate[body
, SynchronousInitialization -> False
, Initialization :> (Pause[1])
, Method -> {"TemplateExpand" -> True}
]]

and find out that this preview is defined in Manipulate`Dump`initDisplay. So here's a quick helper function to replace it:

replaceInitScreen[
  manipulate_,
  newInit_
] := RawBoxes[
  ToBoxes[manipulate] /. 
   HoldPattern[Manipulate`Dump`initDisplay[False]] -> newInit
]

replaceInitScreen[
 Manipulate[body, SynchronousInitialization -> False, 
  Initialization :> (Pause[1]), Method -> {"TemplateExpand" -> True}],
 Row[{ProgressIndicator[Appearance -> "Percolate"], "Please wait..."}]
 ]

enter image description here

It works but it is not a recommended way, consider it an exercise.

recommended approach

What you should do it to take it in your hands and do something like:

DynamicModule[{initDone = False}
, Panel @ Dynamic[
    If[ Not @ TrueQ @ initDone
    , Row[{ProgressIndicator[Appearance -> "Percolate"], "Please wait..."}]
    , body
    ]
  , TrackedSymbols :> {initDone}
  ]
, UnsavedVariables :> {initDone}
, SynchronousInitialization -> False
, Initialization :> (Pause[1]; body = "whatever"; initDone = True)
]

Read more in closely related:

Working with DynamicModule: Tracking the progress of Initialization

$\endgroup$
1
  • $\begingroup$ I used your code in a simple way, as a "wrapper" with body = Manipulate[...] and work well as I wanted. Thanks. $\endgroup$
    – wmora2
    Nov 9, 2017 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.