3

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

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
wmora2
  • 589
  • 2
  • 9
  • 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. – Nasser Nov 09 '17 at 01:58

1 Answers1

2

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

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • I used your code in a simple way, as a "wrapper" with body = Manipulate[...] and work well as I wanted. Thanks. – wmora2 Nov 09 '17 at 15:27