MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Auto-Animate Button ?

  • To: mathgroup at
  • Subject: [mg8377] Re: Auto-Animate Button ?
  • From: "Theodore W. Gray" <theodore>
  • Date: Tue, 26 Aug 1997 20:41:12 -0400
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

> This button create new notebook and draw graphics.
> But SelectionMove is evaluated before end of draw graphics.

The reason is that the SelectionEvaluate is executed asynchronously.
This is a very good thing, most of the time!  In your case, however,
what happens is that SelectionEvaluate initiates the evaluation
in the kernel, and then the front end continues processing the
button function.  You want the remainder of the commands to be
executed AFTER the evaluation finishes.

The easiest way to do this is to make them a part of the command
that you evalate in the kernel.  For example, evaluate the following
definition somewhere:

StartAnimation[t___] := (
SelectionMove[EvaluationNotebook[], All, GeneratedCell];
SelectionAnimate[EvaluationNotebook[], t];

and then modify your button function to read:

                "Do[Plot[Sin[x+t],{x,0,2 Pi}],{t,0,2 Pi}];
      ButtonStyle->"Evaluate"]], "Input",

(My way of selecting all the output cells is somewhat
more reliable than yours.  It guarantees that the correct group is
selected even if the user has moved the selection point manually
during the evaluation.  It also automatically closes the cell group,
so only the first graphic is visible.)

You can read about many of these issues in my new book,
The Beginner's Guide to Mathematica V3, available at:

Theodore W. Gray

  • Prev by Date: calculate not in the decimalsystem
  • Next by Date: Re: Simplifying Sqrt[a^2*d^2] -> a*d
  • Previous by thread: Auto-Animate Button ?
  • Next by thread: Wickham-Jones Graphics & Mma 3.0