12
$\begingroup$

I have a question about creating a docked cell that will let me choose files.

This is just as much a "design" question as a Mathematica question.

I'm a math teacher and I want to bundle a bunch of Mathematica lesson content into a unit.

I have a whole bunch of files that make up a unit. We'll call them simply Lesson1.cdf, Lesson2.cdf, Lesson3.cdf etc. We'll say there are 10 of them.

I wanted to build the unit in smaller pieces , since it seems logical not to have a huge amount of info in one file. So, create in pieces.

I can see how to use ActionMenu to do this... at least it's one way, not saying it's the best way!!

b1 = ActionMenu["Open a lesson", 
  {"Lesson 1" :> 
    NotebookOpen[FileNameJoin[{NotebookDirectory[], "lesson1.cdf"}]],
   "Lesson 2" :> 
    NotebookOpen[
     FileNameJoin[{NotebookDirectory[], "lesson2.cdf"}]]},
  Appearance -> "PopupMenu"
  ]

It works...

I then create a docked cell in the Notebook...

    SetOptions[SelectedNotebook[], 
  DockedCells -> Cell[BoxData[ToBoxes[b1]], "DockedCell"]];

This too works... so far so good!

So , sadly, that's as far as my knowledge will take me.

I tried using hyperlinks to open the lesson notebooks from a main document, but it seemed really cluttered , having more than one notebook open on screen. This method seems potentially better, but can I have it close the "calling" notebook when it opens the selected lesson?

Would there be an easy way to write this docked cell to all the other lessons? (Yes, I think I could do that by just getting a list of lesson files and setting their options for docked cells)

Finally, this way of opening the notebooks generates the "unsafe" content warning. That will be bad since then every lesson notebook will have this issue.

Way over my depth here, but hoping someone can give some "design" advice for packaging up a bunch of notebooks into a nice unit, and being able to get from one to another easily.

My students do not have Mathematica and are using CDFPlayer to view my lessons.

It's interesting that bundling a "NotebookOpen" inside a Button does NOT trigger the warning, which is a big thing. So, buttons aren't as elegant, but they do work and allow students to move between lessons with no issues.

Current Progress with buttons

But I know that can't be right... I've probably managed to add that path to my TrustedDirectories or something... it's a real nuisance not to be able to do this in a straightforward way...

$\endgroup$
4
  • $\begingroup$ Hi again, I should mention that if I create a BUTTON, to open a file, I got no "unsafe content" warning. I.E. I can create a button that opens a file, and dock that, and it does what I want. But it looks pretty clunky having 10 - 15 buttons at the top of a document to open the other files in the unit. But it does work... Tom $\endgroup$ Sep 12, 2012 at 19:28
  • 2
    $\begingroup$ Tom what you seem to be wanting to do is the sort of thing Eric Schulz outlined in an online CDF workshop.The materials from his presentation are available for download from Wolfram. $\endgroup$ Sep 12, 2012 at 21:53
  • $\begingroup$ Thanks! Yes, I have those, and they are probably brilliant, but I can manage to decipher the code, and there is one function that he didn't include in his lesson materials. I'm also one step less structured in that I'm just opening single files, not at the "cell by cell" with tags level as he is. I spent a couple hours this afternoon, really wanted to make that work and couldn't manage it. $\endgroup$ Sep 12, 2012 at 21:57
  • $\begingroup$ It seems to me that the underlying quesion is "why doesn't an ActionMenu work in a docked cell." They don't inside my toolbars. $\endgroup$ Sep 17, 2012 at 3:08

1 Answer 1

11
$\begingroup$

1- Closing the notebook you're in could be done with:

NotebookClose[InputNotebook[]]

Note that this closes without warnings and saves (tip R.M.). Use NotebookSave to manually save the notebook or set the notebook's NotebookAutoSave to True to save after every result.

2- Notebooks[] will give you a list of open notebooks, so mapping your SetOptions over this will give all open notebooks the docked cells

SetOptions[#,   DockedCells -> Cell[BoxData[ToBoxes[b1]], "DockedCell"]]&/@Notebooks[]

You can use Select/Cases and NotebookFileName to find specific notebooks. Or set the option when you open a notebook and have its link at your disposal.

3- With respect to CDFs: they have published restrictions regarding importing/getting external stuff. In many cases (among other things, for loading notebooks which is your requirement) you'll need Player Pro (see feature table).

4- More about notebook security (which relates to the warning you mention in your question) can be found here.

$\endgroup$
2
  • $\begingroup$ It's a de Vries party! $\endgroup$
    – rm -rf
    Sep 12, 2012 at 21:15
  • 1
    $\begingroup$ @R.M I felt obliged to answer ;-) $\endgroup$ Sep 12, 2012 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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