# A standalone notebook that just shows a Manipulate and hides all other code?

I have a complex notebook with one cell that contains a bunch of initial definitions, several modules, and finally a Manipulate object. For a simple example take

(* Some initial definitions *)
a = 2;
(* Some modules *)
f[x_] = Module[{}, x + 1];
(* Output of Manipulate *)
show[] = Module[{}, Manipulate[f[x], {x, 1, 10}]];


I can evaluate this cell and call show[] to display the Manipulate object. However, I would like to give this program to someone who

• has a functioning installation of Mathematica on their computer
• does not have the slightest clue how to use Mathematica,

hence I would like to give them a file (.nb or other, if necessary accompanied by further files) such that they

1. Click on said file to open it in Mathematica
2. after which the initialization code in the first cell gets evaluated automatically and
3. the Manipulate object with the slider and output is shown to them, whereas
4. they do not see any of the code.

I thought that this must be a pretty common and straightforward problem, but after two hours of googling without a satisfying result I would like to ask:

What is the easiest way to achieve this with Mathematica? Or if its not entirely possible, how can I get closest to such a standalone type of notebook?

Can I, for example, outsource all code into an external file and run it automatically when opening the notebook file?

• I've done it for class, but perhaps for smaller apps than yours. I've used SaveDefinitions -> True and Initialization :> (long code). I've also used local variables to store data: {{problems, {"Prob 1", "Prob 2",...}, ControlType -> None}. These get initialized when the DynamicModule is instantiated. I haven't initialized from an external file/package. I'd think it would be possible unless there's a time constraint that is exceeded. The Demonstrations Project consists of all Manipulate apps with no code. Aug 20 '21 at 14:25
• In addition to the above, I would then double-click on the cell bracket around the manipulate only, and then it will hid the code. I’ve done this for a number of files that I have sent to students. Aug 20 '21 at 20:44
• Thanks for the ideas. What I did in the end was to put almost all of the code into a separate file. Then added an initialization cell which loads the external code and displays the Manipulate item, minimize that initialization cell, and insert a big button which starts the evaluation of the initialization cell. This is working quite well for my purpose. Sep 8 '21 at 7:11