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.

The following screenshot shows a toy example to illustrate what I want to accomplish:

enter image description here

The above mimics the structure a type of notebook that I want to deploy for both Mathematica and PlayerPro environments. In actual use, an accompanying package handles the heavy work load.

What I need to do -- I need to make deploying these notebooks as simple as possible. Especially, I don't want to have to manually configure a bunch of settings on each computer where they will run.

Examples of the kind of settings that I want to accompany the deployment include:

Notebook Options, Evaluation Options, InitializationCellEvaluation -> True
Notebook Options, Evaluation Options, InitializationCellWarning -> False
Notebook Options, Notebook Properties, CellGrouping -> Manual
Notebook Options, File Options, Editable -> False
Notebook Options, File Options, Saveable -> False
Notebook Options, File Options, ClosingSaveDialog -> False 

Cell Options, Display Options, ShowGroupOpener -> True 

Don't forget the groups - In addition to the above, on my development machine I set specific groups of text cells. I would like these groups preserved when I deploy the notebooks.

Some of the problems

Some things seem inconsistent. I can create an initialization cell, but if the target platform hasn't had the following set:

Notebook Options, Evaluation Options, InitializationCellEvaluation -> True

the cell won't run on opening the notebook. I haven't found a way to do this programmatically from the deploying notebook.

Grouping of text cells (maybe all grouping) disappears when I've tested deployment.

Questions

So, can a notebook deployed to a Mathematica environment, different from the one on which one created it or similarly to a PlayerPro environment, encapsulate all such configurable FrontEnd options (including the grouping of cells)?

To clarify, if I make an application and configure all these options on my development machine, how can I distribute the application such that it will carry ALL such settings to different machines, platforms, or even operating systems?

An explanation for how the developers think about this might better help me/everyone understand how to do this.

How do I go about doing this? Can one configure such FrontEnd options programmatically from an initialization cell? This seems unlikely given the chicken and egg problem.

Can some lower level call do this? Can some accompanying stylesheet do this? Can some other configuration means do this?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Most of the options you want to set are actually options for Notebook or Cell, so when changing them globally you only change their default values for new notebooks and cells. You can (and should) set these options not globally but only on the notebook level for the notebook you want to deploy. To do this use the option inspector, not the preferences dialog and make sure to select "Selected Notebook" for the "show option values" popup in the top of the option inspector. Don't forget to save the notebook after making these changes. As the notebook-file is a plain text file you can check whether these options are really set by looking at the file with a text editor (you can even change them there, but that destroys the cache information and/or signature and will make the notebook not work in PlayerPro and CDF-Player anymore).

Only the two options InitializationCellEvaluation and InitializationCellWarning are really FrontEnd settings that can't be set on the notebook level. Their purpose is a security measure: by setting those you ensure that a notebook you open doesn't automatically execute code -- which might do evil things. That purpose would of course be anulled if it would be possible to set up a notebook which changes their settings automatically. So except for potential defects (security holes) I don't think you can set those as you desire. What you could do is to show a warning if they are set and offer a button to change them.

What I would recomment is to slightly change the loading mechanisms of your deployed notebook so you don't even have to set these global options, with e.g. changing your code to something like this:

Needs["Units`"];

DynamicModule[{d = ""},
  Column[{
   Button["Evaluate",
    d = Plot[Sin[x], {x, 0, 6 Pi}, ImageSize -> 200, 
    PlotLabel -> Pascal],
    Method -> "Queued"
   ],
   Dynamic[d]
  }],
  Initialization :> (Needs["Units`"])
]

For deployment of this, you would typically make a copy of the notebook after evaluation, then delete the input in the copy and deploy the copy with just the resulting output cell. In the Initialization you can basically do everything that you did in the initialization cells, e.g. load packages, define functions and variables or even load and preprocess data. There are some peculiarities with that, but AFAIK it is the recommended functionality for applications to be deployed for PlayerPro or the CDF-Player. Here are two references which explain the most obvious peculiarities: context issues, evaluation order.

If you get this working, you will still get a warning about "Dynamic Content" before the code executes if you open the notebook -- unless you put it into one of the "trusted" directories which you can find and change in either the option inspector or the preferences dialog.

share|improve this answer

Your Answer

 
discard

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.