mgonzal
(Mariano Gonzalez)
1
(* This works *)
anima = False;
Button["Iniciar/Detener", If[anima, anima = False, anima = True];
Print[anima]]
(* But this does not work *)
anima = False;
Button["Iniciar/Detener", If[anima, anima = False, anima = True];
If[anima,
ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}]]]
Setting the Button as a Control in a Manipulate works
anima = False;
Manipulate[
If[anima, ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}], ""],
Button["Iniciar/Detener", If[anima, anima = False, anima = True]],
AppearanceElements -> None
]
A minor, cosmetic, improvement (FrameMargins → None):
anima = False;
Manipulate[
If[anima, ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}], ""],
Button["Iniciar/Detener", If[anima, anima = False, anima = True]],
AppearanceElements -> None, FrameMargins -> None
]