I am about to start constructing a UI that will be run with Player Pro. I have created the following notebook and marked it cells as initialization cells.

PlotUi[] := 
     Plot[Sin[a x], {x, -2 \[Pi], 2 \[Pi]}], {{a, 1}, -2, 2}]}];


When I select File | CDF Preview | Player Pro I get a Player Pro window that shows me the code. I have to actually execute the code to show the UI. How can I get the UI to auto-load from the initialization cells and hide (close?) the notebook when it is opened? Also, how would I close the notebook when the GUI is closed.

The UI will be a processing wizard and the users should not have to execute (or see) any Mathematica code.

  • $\begingroup$ Do you really need to use the old GUIKit, or can you use the newer UI construction methods? $\endgroup$
    – Szabolcs
    Aug 21, 2015 at 13:09
  • $\begingroup$ @Szabolcs I thought that was the way to create more robust GUIs. I don't have to use it. I'm using 10.2 $\endgroup$
    – Edmund
    Aug 21, 2015 at 13:10
  • $\begingroup$ @Szabolcs I removed the GUIKit and put in a Manipulate. $\endgroup$
    – Edmund
    Aug 21, 2015 at 13:19
  • 1
    $\begingroup$ I can't comment on what is more robust, but I think I do know the solution for Dynamic GUIs (untested): instead of evaluating CreateDialog, which creates a dialog notebook, just make the dialog notebook the notebook that the user will open. The point is that the dialog itself is a notebook. You can have a DynamicModule within which can have an Initialization :> ... option for any setup. But the GUI (at least the part that shows first) doesn't need to be created by evaluating something. It's just saved in the notebook. $\endgroup$
    – Szabolcs
    Aug 21, 2015 at 13:32
  • $\begingroup$ This of course won't work with GUIKit, but you can have a normal button in the notebook which will launch the GUIKit UI. I don't know if there are other ways. I don't have and have never used Player Pro, so this is based on plain Mathematica experience. $\endgroup$
    – Szabolcs
    Aug 21, 2015 at 13:34

1 Answer 1


I save notebooks with multiple GUIs as CDF files and give users CDFPlayer to install.

I have code in the notebook but hide it by collapsing the cells around the GUI that I want the user to see (of course the user can open it and sometimes does by accident).

For your particular problem you could write in your notebook something like:

 "Plot Sin[a x]",
 Manipulate[Plot[Sin[a x], {x, -2 \[Pi], 2 \[Pi]}], {{a, 1}, -2, 2}]

and then double click on the string "Plot Sin[a x]" to get the Manipulate in a popup window.

You can make it look more appealing by a myriad of tricks.

For example to make it stand out a bit you could enclose it in frame and use TraditionalForm for the Sin[a x] expression.

 Framed[Row[{Style["Plot ", 14], 
    Style[TraditionalForm[Sin[a x]], 14]}], Background -> LightCyan],
 Manipulate[Plot[Sin[a x], {x, -2 \[Pi], 2 \[Pi]}], {{a, 1}, -2, 2}]

Once you collapse it this is all the user sees

Mathematica graphics

  • $\begingroup$ This is an interesting idea but I would not want the users to have to launch the interface after opening the application. Saving the CreateDialog with Export is ideal as it loads the UI as needed when the file is open. I do like your idea for a menu of UI wizards but with NotebookOpen on the dialogue notebooks instead of PopupWindow. $\endgroup$
    – Edmund
    Aug 22, 2015 at 13:58

Your Answer

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

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