Message Boards Message Boards

Button[ ] doesn't work?

Posted 3 years ago

(* 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}]]]
POSTED BY: Mariano Gonzalez
3 Replies
Posted 3 years ago

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
]
POSTED BY: Hans Milton

Thanks for your help.

POSTED BY: Mariano Gonzalez
Posted 3 years ago

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
]
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract