# Drawing an arrow pointing at the “Enable Dynamics” button

Sometimes my students are given Mathematica notebooks as part of an assignment, and asked to go through some demonstrations contained in the .nb file. A lot of times I get complaints that the "graphs aren't showing up" or "all I see is lines of code". The problem usually is that they haven't enabled dynamics on that particular notebook.

What I'd like to do is have an arrow contained in the notebook that points directly at the "Enable Dynamics" button which shows when a notebook is opened. Then, once the button is clicked, the arrow disappears.

I know how to draw an arrow, but what I don't know how to do is:

1. Have that arrow point to the corner of the notebook window, where the button is;
2. have that arrow disappear once the button is clicked.

Any help or pointers on this would be sincerely appreciated!

-
FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]] will toggle the setting (but it isn't an on-off thing!) – Dr. belisarius Dec 12 '13 at 4:00

I would approach this problem a bit differently. I would provide each such notebook with an initialization button at its top, right under its title, if any. By pressing this button, the dynamic apdating would be enabled. How to do it technically, is already in the comment of belisarius. The further is only a question of a design. The latter should be catching attention, so that even a lazy student would immediately notice it. That depends, of course, of a personal taste of yours. I would propose the following:

    Button[Style["Initialize: press me before you start", Red, Bold],
FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]],
ImageSize -> {350, 20}]


When you prepare the notebook, evaluate once this code. The button will appear in the output cell. I propose to select then the cell bracket and to click Menu/Format/Text Alignment/Align Center. The button will be centered. You then can collapse the input cell (go to Menu/Cell/Cell Properties and uncheck "Open"). The notebook will look like this: As one reasonable extension, you might want to include evaluation of initialization cells into the same button:

    Button[Style["Initialize: press me before you start", Red,
Bold], (FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]];
FrontEndExecute[FrontEndToken["EvaluateInitialization"]]),
ImageSize -> {350, 20}]


Have fun.

-
Wouldn't the usual Mathematica button still display when this notebook is opened? – Steve D Dec 12 '13 at 23:35
Does including the EvaluateInitialization action really provide any functionality that cannot already be obtained by suitably setting the notebook's options? (That is, NotebookOptions > Evaluation Options > InitializationCellEvaluation : True) – murray Dec 15 '13 at 22:38
@murray In principle it does not. I did not know about the possibility you write about and tried it just now. In my case the InitializationCellEvaluation are preset to Automatic and are blended out. No access to it therefore. I would prefer this way, if accessible. Have you an idea, how to make it active? HMy proposal to include evaluation of initialization cells into the button has the background that there is anyway a button to enable dynamics. So, why not to include there everything. – Alexei Boulbitch Dec 16 '13 at 8:21
@Steve D Yes, you are right. The button is already there. Your problem is (as much as I understand it) that the students are too lazy or, may be, not curious enough to notice the button at the margins and to press it. So it is more a psychological question, then a programmatic one. My idea is that as soon as there is such a button inside the notebook, as I propose: a rather large and bright, carrying a text demanding to press it in the beginning of their work, the students will more easily notice it and understand that they should press it. – Alexei Boulbitch Dec 16 '13 at 8:32
@murray I realized that this should be fixed Globally, rather than for the selected document. It is a great possibility, but with one draw back. Fixing such an option globally prohibits to export documents into cdf. Otherwise it is, indeed, an excellent solution. Thank you. – Alexei Boulbitch Jan 13 '14 at 9:11

According to my rough test, the DynamicUpdating option used at the Notebook level can override the global setting. To demonstrate that, here is a simple test.

1. Start a fresh new Mathematica, and goto Evaluation menu, uncheck the Dynamic Updating Enabled term.

Or goto the Option Inspector, select Global Preference, then set Cell Options -> Evaluation Options -> "DynamicUpdating" to False.

Note: According to Jacob Akkerboom, this is equivalent to SetOptions[$FrontEnd, DynamicUpdating -> False]. Also note it overrides the Dynamic Updating Enabled menu setting. 2. Using any text editor to create the following two Notebook files: Notebook[{Cell[BoxData[DynamicBox[ToBoxes[Date[],StandardForm],UpdateInterval:>0]],"Output"]}]  Notebook[{Cell[BoxData[DynamicBox[ToBoxes[Date[],StandardForm],UpdateInterval:>0]],"Output"]},DynamicUpdating->True]  3. Open them in Mathematica, we can see despite the dynamic-updating being globally disabled, the later Notebook still functions. ## Notebook Security About Kuba's comment on the safety issue, I think it won't be a problem, as when the nb file is NOT on a "TrustedPath", Mathematica will always detect unsafe dynamic content and raise an alarm if there is any, even the global dynamic-updating is set to True. Here is a simple test. 1. Set SetOptions[$FrontEnd, DynamicUpdating -> True].

2. Using any text editor to create the following two Notebook files, which contain unsafe dynamic function FileNames[ ]:

Notebook[{Cell[BoxData[DynamicBox[ToBoxes[FileNames[],StandardForm],UpdateInterval:>0]],"Output"]}]


Notebook[{Cell[BoxData[DynamicBox[ToBoxes[FileNames[],StandardForm],UpdateInterval:>0]],"Output"]},DynamicUpdating->True]

3. Open them in Mathematica, we can see both of them being alerted.

So in my opinion, it should be as safe as other method to use this DynamicUpdating option at the Notebook level.

Note: There IS a potential unsafe issue as described by Jacob Akkerboom. That is, when there is an alarm bar as shown above, you can ignore it but just run some code with dynamic function (like as simple as Dynamic[]) to enable the dynamic-updating, which also cause the former forbiden dynamic Cell to work, which may contain harmful code!

-
Are you sure it works? – Kuba Dec 12 '13 at 13:53
@Kuba I saved a nb with a cell Cell[BoxData[DynamicBox[ToBoxes[Date[],StandardForm],ImageSizeCache->{249.,{2.,‌​8.}},UpdateInterval:>0]],"Output"] and with this option set to True, opened a fresh new MMA, disabled the dynamic updating from menubar, then I opened the nb, it works. – Silvia Dec 12 '13 at 13:59
Strange, it does not work for me. Aren't testing that in safe directory? Maybe it's OS specific, I'm on Win7. But at the end, it would be strange if such simple soultion is walkaround for protection procedure. – Kuba Dec 12 '13 at 14:03
@JacobAkkerboom Hmm.. I think it's Infinity by default. Infinity means the dynamic object will not refresh unless something in it explicitly changed. And I think Dynamic[Date[]] should NOT refresh by default. Have you changed anything else? – Silvia Dec 13 '13 at 16:01
Ah Silvia thank you! I was getting worried :). x=0; Dynamic[x++] works as expected :). By the way I have found that Options[\$FrontEnd, DynamicUpdating] changes the setting in the option inspector. I think this option sets the value of DynamicUpdating for new notebooks. It is not the same as the option from the evaluation menu, as DynamicUpdating affects whether Buttons work or not, whereas the menu option from the evaluation menu does not. But I guess it does largely the same thing. So +1, I think this is the best answer. Maybe you can also mention that setting the option of a ... – Jacob Akkerboom Dec 13 '13 at 17:46

How about a cell at the top of the notebook containing a message to click the button, which then deletes itself when dynamic updating is enabled:

DynamicWrapper[Style["Click the stupid button! \[UpArrow]", "Title"],
SelectionMove[EvaluationNotebook[], Before, Notebook];
SelectionMove[EvaluationNotebook[], Next, Cell];
NotebookDelete[]]


Note that the input cell will eat itself as soon as you evaluate it. If you then close and save the notebook, then re-open it, you should find that the message disappears after the enable dynamics button is clicked.

-
+1 Clever! I think the notebook manipulating functions make the dynamic-updating in this nb always be disabled by default? – Silvia Dec 13 '13 at 4:24