Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]] will toggle the setting (but it isn't an on-off thing!) –  belisarius Dec 12 '13 at 4:00
add comment

3 Answers

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], 
 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:enter image description here 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"]];
 ImageSize -> {350, 20}]

Have fun.

share|improve this answer
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 at 9:11
add comment

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.

    option inspector

    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 comparison


  3. Open them in Mathematica, we can see despite the dynamic-updating being globally disabled, the later Notebook still functions.

    comparison in mma

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[ ]:


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

    forced DynamicUpdating notebook 2

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!

share|improve this answer
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
show 21 more comments

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];

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.

share|improve this answer
+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
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.