MathGroup Archive 2003

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

Search the Archive

Re: CellAutoOverwrite

At 03:43 PM 9/30/2003, Florian Jaccard wrote:
>Hello everybody,
>For personal training purpose, I'd like to create my own clock.
>It works fine, but each second, a new drawing is being created. After a few
>minutes, my notebook becomes too big...
>Is it possible to delete automatically the old drawing when the new is being
>created ?
>If CellAutoOverwrite is the option I need, does somebody know how to use it
>Thank's for help !
>Florian Jaccard

I came up with a nice little clock program a while back. It even runs in 
its own kernel, so you can keep working while the clock is ticking.

It's based on the frontend programming techniques outlined in our latest ezine:

To run it do:

In[1]:=<< Clock`

Here's the package code. Put it in one of the standard locations.

BeginPackage["Clock`", "Graphics`Arrow`"]

Clock::usage = "Clock[{hour, minute, second}] creates a Graphics image of 
an analog clock\
at the given time. Clock[] uses the current time."

ClockinNB::usage = "ClockinNB[] places a running analog clock in a separate 


ClockinNB::noaux = "This function requires that a kernel named \"Aux\" be 

loc[ang_] := {Sin[ang], Cos[ang]}

Clock[{h_, m_, s_}] :=
Module[{hang, mang, sang},
   {hang, mang, sang} =
       2 Pi {h/12 + m/(12*60) + s(12*60*60), m/60 + s/(60*60), s/60};
         Circle[{0, 0}, 1.2],
         Text[StyleForm["12", "Title"], {0, 1}],
         Text[StyleForm["3", "Title"], {1, 0}],
         Text[StyleForm["6", "Title"], {0, -1}],
         Text[StyleForm["9", "Title"], {-1, 0}],
         Map[Line[{.9 loc[#], loc[#]}] &, 2 Pi/12 {1, 2, 4, 5, 7, 8, 10, 11}],
         Point[{0, 0}],
         Arrow[{0, 0}, .6 loc[hang]],
         Arrow[{0, 0}, loc[mang]],
         Line[{{0, 0}, .9 loc[sang]}]},
       AspectRatio -> Automatic, ImageSize -> 200]

Clock[] := Clock[Floor/@Take[Date[], -3]]

ContinuingClock[nb_NotebookObject] :=
While[MemberQ[Notebooks[], nb],
       NotebookFind[nb, "clock", All, CellTags, AutoScroll->False];
         Cell[GraphicsData["PostScript", DisplayString@Clock[]], "Graphics",
         ImageMargins->{{0, 0}, {0, 0}}, CellTags->"clock"]];

ClockinNB[] :=
   If[("Aux"/.(EvaluatorNames/.Options[$FrontEnd, EvaluatorNames]))==="Aux",
     nb = NotebookPut[Notebook[{
       Cell["<<Clock`", "Input",
         CellOpen->False, CellTags->"clock"],
       Cell["Clock`Private`ContinuingClock[EvaluationNotebook[]]", "Input",
         CellOpen->False, CellTags->"clock"],
       Cell[BoxData[ButtonBox["Quit", Active->True,
         ButtonFunction:>NotebookClose[ButtonNotebook[]]]], "Text"]},
       ShowCellBracket->False, Evaluator -> "Aux", WindowSize->{210, 250},
       WindowFrame->"Palette", WindowElements->{}, WindowFrameElements->{},
       WindowMargins->{{Automatic, 0}, {Automatic, 0}}, WindowTitle->"Clock",
     SelectionMove[nb, All, Notebook];


Module[{evs = EvaluatorNames /. Options[$FrontEnd, EvaluatorNames]},
   If[("Aux" /. evs) === "Aux" && $SystemID=!="PowerMac",
       SetOptions[$FrontEnd, EvaluatorNames -> Append[evs, "Aux" -> {}]]


Omega Consulting
"The final answer to your Mathematica needs"

  • Prev by Date: Re: Linux & Mathematica 4.2:NotebookDirectory is not a known option
  • Next by Date: Re: Something really wrong with FindRoot or NDSolve in Mathematica 5.0
  • Previous by thread: Formations Mathematica
  • Next by thread: Dot - mystery consumption time