I believe I am missing an important piece of information. I am trying to execute a simple If statement inside a DynamicModule. The variable tested in the If statement is a Dynamic variable, in this case, a Number. As it can be seen from the elementary (but wrong) few lines of code the If statement does not work because the tested variable "active" is not a Number (NumberQ=False).
DynamicModule[{active = 0},
If[active == 0, color = Green, color = Red];
(*--- Output and Dynamic Input ---*)
Column[
{
Panel[Style["Result", color, Bold]],
Panel[Row[{"Setting@active= ", Setting@active, " ",
"NumberQ[Setting@active]= ", NumberQ[Setting@active]}]],
Panel[Row[{"Dynamic[active]= ", Dynamic[active], " ",
"NumberQ[Dynamic[active]]= ", NumberQ[Dynamic[active]]}]],
Button["Set active=True", active = 1;, Method -> "Queued",
Background -> Green],
Button["Set active=False", active = 0;, Method -> "Queued",
Background -> Red]
}]
]
I assume the issue is trivial ... but as I said, I think I am missing a basic piece of knowledge here. Any assistance is most appreciated. Many thanks in advance.
Manipulate
the body ofDynamicModule
does not refresh on any changes. You need to take care of that, changecolor
inButtons
or take a look atDynamicWrapper
. $\endgroup$ – Kuba♦ Jul 26 '17 at 10:47