Message Boards Message Boards

Create a Package to write text and calculation results to a Notebook?

Posted 8 years ago

I am familiar using the Notebook interface interactively for myself to write programs, and graph and display results various forms (e.g., in lists, Grid, DataSets, various plots types, Panel, StringForm etc.). It is easy, fun and I have learn much about Mathematica during the last year.

I now want to write a simple application (a prototype, but one that I will show others), on my desktop (PC or MAC), which "hides the code" and gets all user input to the application via user dialogs using the various built-in dialog related functions. The ultimate intention is to create a web-based application, one that may ultimately get deployed on the Wolfram Cloud to support several dozen concurrent users (users that know nothing about Mathematica), after some further RE-DESIGH for the web deployment.

CDF is not adequate.

My questions are:

1.) To build the desktop prototype of the application, must I create a "Package", or is there a simpler way to display the results of calculations (text and numbers in tables and graphs), into a "user-facing" Notebook different from the Notebook in which the code resides?

(I looked using the Low-Level Notebook Programming routines, e.g., NotebookWrite, while it can be made to work for these purposes, it seems overly complex, having to nest some Grid formatted data inside of things like:

NotebookWrite[nb5, Cell[BoxData[ToBoxes[somegriddata]], "Output"]]

, but I can do it that way, I think, if I have to).

2.) Am I crazy to even thing about approaching my prototyping effort this way, if ultimately I want a multi-user web-based application?
(But I am concerned that the Wolfram tools available for data display and user dialog in the Wolfram Cloud are much too limiting (e.g., FormFunction, is about all I have found for input from the user), to make a good web app.

NOTE: At age 64, and only an amateur programmer, I am woefully not familiar enough with using all the modern Web-based application programming environments based Java Script, Python, HTML5 etc. and their required IDEs. Otherwise I would not be even thinking about using Mathematica for this application, since it is not computationally intensive/complex.

Thank you in advance for any thoughts you might have on these matters. - Rick

POSTED BY: Richard Forberg

Here are some loose thoughts. Quite subjective so keep a distance :)

The purpose of the package is to have nice and tidy text file you can easily maintain with versioning software like Git. The next important purpose is to have contents' contexts managed well. This is done with BeginPackage and friends.

You can write code in notebook but because of its box structure it's not perfect for Git.

I'm encouraging you to read official tutorials about packages as well as online accessible stuff:

MMA.SE: What constitutes a package

On the other hand packages are not always perfectly getting along all possible deployment options in WL world. E.g. self contained cdf for FreePlayer:

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

The first question you should answer yourself is "what is the target environment". It seems you've picked Wolfram Cloud. Ok, now you have to read what are its limitations. For FreePlayer for example, you can't use Import/Export or dialogs. For Cloud, even though new features and fixes are continuously updated, you will face problems. Also, almost everything is calculated cloud side so you will face performance limitations. Not major but it won't work "smoothly" in near future because of that. That's the cost of being able to easily develop web apps incorporating WL power.

If you want Cloud based user interface, develop it on Cloud, not on desktop MMA. Maybe it is not the fastest or the most convenient way but it will save your time since you can catch "issues" immediately (e.g. evaluate this on cloud and desktop: MessageDialog[1]).

Ad 1. CloudDeploy should take care about saving all definitions needed for the content. But for general and big app I'd just include Needs/Get inside your UI elements and put the package on your Cloud $Path. It will be easier to manage and write complex things. Lowlevel notebook programming functions are useful but I wouldn't say they should be the core of custom GUI. Use what's there DynamicModule + PaneSelectors/TabViews/Overlay, etc. Use NotebookWrite and selections only if you really feel like notebook environment is well suited your app purpose.

Ad 2. It's ok to develop Kernel part of you package locally, but as I said, as soon as you start UI/FrontEnd part, move testing to the cloud.

POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract