[Date Index]
[Thread Index]
[Author Index]
Re: CellAutoOverwrite
*To*: mathgroup at smc.vnet.net
*Subject*: [mg44002] Re: [mg43708] CellAutoOverwrite
*From*: Ezine <ezine at omegaconsultinggroup.com>
*Date*: Fri, 17 Oct 2003 05:14:27 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
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 !
>
>Greetings
>
>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:
http://omegaconsultinggroup.com/Services/HTMLLinks/ezv2i09_4.html
To run it do:
In[1]:=<< Clock`
In[2]:=ClockinNB[]
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
notebook."
Begin["`Private`"]
ClockinNB::noaux = "This function requires that a kernel named \"Aux\" be
defined."
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};
Graphics[{
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}],
PointSize[.05],
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];
NotebookWrite[nb,
Cell[GraphicsData["PostScript", DisplayString@Clock[]], "Graphics",
ImageMargins->{{0, 0}, {0, 0}}, CellTags->"clock"]];
Pause[1];
]
ClockinNB[] :=
Module[{nb},
If[("Aux"/.(EvaluatorNames/.Options[$FrontEnd, EvaluatorNames]))==="Aux",
Message[ClockinNB::noaux],
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",
ShowSelection->False
]
];
SelectionMove[nb, All, Notebook];
SelectionEvaluate[nb]
]
]
End[]
Module[{evs = EvaluatorNames /. Options[$FrontEnd, EvaluatorNames]},
If[("Aux" /. evs) === "Aux" && $SystemID=!="PowerMac",
SetOptions[$FrontEnd, EvaluatorNames -> Append[evs, "Aux" -> {}]]
]
]
EndPackage[]
--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"
http://omegaconsultinggroup.com
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**
| |