Message Boards Message Boards


Create a user interface and stand alone application using Wolfram Language?

Posted 7 months ago
10 Replies
0 Total Likes

Hi, I have a question about the creation of a stand-alone application and the relative user interface.

I have created many notebooks ok Mathematica using the Button, CreateDialog, Input Field and so on, but i have noticed that the code is hard to hide... For example, if there are some errors during the computation and Mathematica Print the errors, the hidden code appear...

Here is the question: I have created a code for signal processing and data analysis. Are there a possibility to create a stand-alone application, that uses the Mathematica Kernel obviously but that appears only with buttons, menus etc. with which the user can interact to insert data, file path etc.. and start the analysis without seeing the code, in other words, an application with graphical user interface?

I'd like to create a user-friendly software for users that haven't any knowledge of Wolfram Language.

Thank you

10 Replies

Have you tried SaveDefinitions? It should make the output cell self-contained, so that you can delete the source code.

Posted 7 months ago

Thank you, but SaveDefinitions is an option of Manipulate and i don't use that function...

A very small example of what i mean:

Button["Create an energy calibration",
 fit = CreateDialog[
    Column[{"Insert a pair of point like {voltage,energy}", InputField[Dynamic[pointcal]], Button["Proceed",
       fit = Fit[pointcal, {1, x}, x];
       , ImageSize -> Automatic]}]];

The user clicks on this button and inserts the required data and the computation is performed. This is a simple example, so if i hide the code with the cell on the right it works, but for more complicated codes is fore difficult and it is always not "safe" as i wrote in the previous post (with an error the code appear)

Thank you

How about Quiet? This should suppress error messages.

Andrea, designing a Mathematica application is a good idea. If you are interested in a guide to how to design a pretty much standard application look at A Mathematical Style at my web site.

I would be wary of writing notebooks for others that are just buttons and dynamic displays. It might be better to write 'literate' notebooks that have textual discussion mixed with the displays and look more like a paper. Most dynamic displays are not that self-explanatory.

A second method for hiding code, beside double clicking on the cell bracket, is to use the Mathematica Menu, Cell, Cell Properties/ Open command. (Alt+CPO) This semi-permanently closes a cell. The reader can open it if he wishes but normally it will stay closed, even between sessions. One advantage is that you can have textual discussion, hidden code, and then output so the notebook reads like a paper. Another advantage is that most code for many displays, such as graphics or dynamic displays, is one-off and it's very convenient to put it just where it's used.

The disadvantage is that the closed cell is very narrow and readers might miss it and not evaluate it. My solution to this was to design an 'Eval' button, which I insert in a Text cell before the code that automatically evaluates the code cell, keeping the cell shut. I have an application, Presentations, which is a help in writing literate notebooks. There is a button on the Presentations palette to paste the Eval button into a notebook so it's very convenient and I use it a lot. If you would like a copy of Presentations write me and introduce yourself and I'll send you a link.

Another technique with complicated displays is to put them in windows (which you already know how to do) that can be positioned next to the notebook. Then if there is a lengthy discussion in the notebook it can be scrolled without losing sight of the associated display.

Lookup Manipulate, CDF (format) and related topics.

There are few tutorials too:

Posted 7 months ago

Thank you David, you gave me some useful ideas! The simple option of "open cell" seems powerful, and there is no problem with the missing of the cells because there will be ever a button to evaluate it!

I understand and share your opinion about an only-graphics application, in fact, my idea is that there will be some text explanation but i don't want to show the code to users, because it's not necessary and can cause problems...

As soon as possible, i'll send you an email for the presentation.

If i include a Print function in the code, every time i evaluate it a new output cell is created. Do you know how to force to update the previous output with the new one (to create only one output cell)?

Thank you Kuba, but the application can't be included in one or more Manipulate functions

[...] the application can't be included in one or more Manipulate functions


While Manipulate can be too top level, see related DynamicModule examples. It supports SaveDefinitions option too.

And in case you have a well written package you can include it using those tips:

How can I include functions from a package into a CDF file?


If i include a Print function in the code, every time i evaluate it a new output cell is created. Do you know how to force to update the previous output with the new one (to create only one output cell)?

Look at PrintTemporary[] -- You can replace a print with a new one and control the display of information. For example, you can print some update information and clean it all up at any point.




I much prefer DynamicModule and the use of the second argument of Dynamic than the Manipulate statement, which I haven't used for years. The Presentations application has a section on using DynamicModule in the context of plane geometry applications and illustrates various techniques. It's easy to define secondary dynamic variables that depend on the primary dynamic variables and keep them updated. DynamicModule also allows complete freedom in formatting the display whereas Manipulate is very restricted. Another thing I do, which might be considered rather trivial and silly, is to have routines phrase and pagelet, which are essentially Row and Column without the extra brackets. It's just more intuitive and shorter to format displays with the controls and graphics going just where you want them.

I also like to use annotated derivations where expressions and displays are interspersed with comments. Print is not best for this because each Print statement creates a new cell. Instead I use pagelet that includes everything within one output cell, and then phrases for individual lines and regular output for computed results. Also you can just include text in quotes. Or you can have a dynamic display where a line of text is a secondary dynamic variable which is updated when appropriate.

Mathematica notebooks are an entirely new communication medium. They are literally orders of magnitude better than printed papers. Thirty years are like nothing. We are still learning how to use them. Many things WRI does are great and other things are clumsy, but the future is bright.

Posted 7 months ago

Thank you all for your advices! I'll try to put them into practice.

@David: I have sent you an email for the presentation

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract