In recent versions of Mathematica, a number of functions have the feature that, while they are thinking (or, for example, loading data from Mathematica servers), they pop-up a little light-blue box that then disappears when the thinking/loading is complete. An easy way to see an example of this is to evaluate a Quantity function after resetting the Mathematica Kernel via Quit[]
; for example:
(* any recognized or unrecognized quantity should work here,
so long as Mathematica was just restarted: *)
Quantity[1, "quuxatons"]
Immediately after entering this, I see a small blue box that says "Interpreting unit ...." which quickly disappears and is replaced with the appropriate error. Notably, this seems to be an output cell that is then either modified or deleted.
I'm wondering how these are created/managed. I'm not overly concerned that the appearance be identical (though it would be nice for consistency); I'm mostly interested in how the cell gets deleted. An example of code I've written in the past is below, and it works just fine, except that the progress message never goes away.
SomeLongRunningFunction[] := Module[
{progress = 0},
Print@Row[
{"Progress: ", Dynamic[progress], "%"},
BaseStyle -> Directive[11, FontFamily -> "Arial", Background -> LightBlue],
RoundingRadius -> 0,
Frame -> True,
FrameMargins -> {{30, 30}, {10, 10}},
Alignment -> {Center, Center}];
Do[
(Pause[0.1]; (* ... *)
progress += 10),
{10}]]
Is there a built-in function for making/managing these temporary messages?
If not, how does one delete a cell that was just printed (like in the example above)?
PrintTemporary
??? Replace yourPrint
with it and see whether that does what you want... $\endgroup$ – Albert Retey Jan 12 '16 at 22:58