WLJS LogoWLJS Notebook

Mini apps

This export option converts a notebook into a window application that uses WLJS as a runtime and works in an isolated context.

Call Share from the top menu or click the icon and choose Mini app:

Share
Mini app

Use cases

  • Calculators and utilities
  • Useful tools for processing data with a GUI
  • Share your notebook in the form of a small app

All initialization cells of the notebook are evaluated on startup, and the last input cell becomes the main window of the app.

Use WLX cells for maximum customization
You can create new windows with CellPrint

How to Prepare a Mini App

In general, you can think of a mini app as if it were an output of a single cell projected (see Project feature) to a window. The following rules apply:

  • The default context ($Context) of all symbols is randomly generated and will be unique for each running instance of your app
  • All initialization cells will be executed automatically on the startup of an app
  • The output of the last input cell will be the first window of your app
  • An app will pick the first available computation kernel in your system

Apart from that, the program for the widget is just a plain WLJS notebook. You can leave cells there for testing and debugging with no impact.

Example 1

Let's write the simplest possible interactive widget:


(* make it initialization cell *)
equation[x_,n_] := Sum[(Sin[2[Pi](2j - 1) x])/(2j - 1), {j, 1, n}]

(* make it the last input cell in the notebook *)
ManipulatePlot[equation[x,n]//Re, {x, -1,1}, {n, 1,10,1}]

Then export it as Mini app and double-click the created file. You can open it anytime on any machine with WLJS Notebook installed.

Example 2


(* make it initialization cell *)
newWindow = Module[{
text = "Hello World"
},
Column[{
EventHandler[InputText[text], (text = #)&],
Graphics[Table[{
	RandomColor[], 
	Rotate[
		Text[text // Offload, RandomReal[{-1,1}, 2]],
		RandomReal[{0, 3.14}]
	]
}, {40}]]
}]
];

and the last input cell:


notebook = EvaluationNotebook[];

Button["Open window", CellPrint[newWindow, "Notebook"->notebook, "Target"->_]]

It will create a window with a single button that, when clicked, creates a new window with its content.

On this page