Update
The other answers provide a good way to add dynamic monitoring using a single kernel when access to the front end is available. The method I proposed using multiple kernels will work even when the front end is not accessible. So, you might ask, when would the front end not be available?
Suppose you have a remote machine, with two kernels, a master/monitor kernel, and a slave/working kernel. It is possible to communicate with the master kernel using the Channel framework. In this situation, one might want to ask the master kernel to check on the status of the slave kernel, and report back diagnostic information. This is in fact a situation that I currently use, and one where I don't think the other answers will work.
I had a stylesheet approach that is not nearly as effective as MrWizard's answer, so I have removed that part of my original answer.
Original answer
Yes, this is possible. First, you need to make sure that your version of Mathematica has multiple kernels defined. Then, you can use Dynamic
(or other symbols that take an Evaluator
option, e.g., Button
or Cell
) to display the value of a symbol in another kernel.
Multiple kernels
You can create additional kernels using the Evaluation | Kernel Configuration Options
menu item. Another method is to use CurrentValue
. For instance, the following returns the list of evaluators that have been defined:
CurrentValue[$FrontEnd, EvaluatorNames]
{"Local" -> {"AutoStartOnLaunch" -> True}, "Local 2" -> {}}
Let's add a new evaluator:
CurrentValue[$FrontEnd, {EvaluatorNames, "Debug"}] = {"AppendNameToCellLabel"->True}
{"AppendNameToCellLabel" -> True}
Check:
CurrentValue[$FrontEnd, EvaluatorNames]
{"Local" -> {"AutoStartOnLaunch" -> True}, "Local 2" -> {},
"Debug" -> {"AppendNameToCellLabel" -> True}}
Dynamic
With multiple kernels, you can use Dynamic
with the Evaluator
option to display the value of a symbol in a different kernel. For example, suppose you have a running computation in kernel "Local". Then, in a notebook running the kernel "Debug", you can evaluate:
Dynamic[a, Evaluator->"Local"]
to display the value of the symbol a
in kernel "Local".
For example, in the following animation, I create two notebooks, one using the kernel "Local", and the other using the kernel "Debug". Then, I start a computation in the "Local" notebook. Subsequently, in the "Debug" notebook, I execute the Dynamic
expression above, which displays the value of a
in the "Local" kernel: