code.py dictates what an algorithm calculator will do once the 'compute' button is pressed.
It is a python source file usually consist of a single function headed
def calculate(context): of which the python intrepreter will call.
Inside it, one can use almost all functions provided by the
sympy library with the exeption of
sympify() or
lambdify() because of security reasons.
In addition, you can also use the semi-oficial function
process_sympy(latex) to convert the latex text in variable
latex to a sympy expression object.
Also, the security function does not really like the math operation shorthands
+=,
-=,
*=, and
/=. So instead of
a += b please use the prefered
a = a + b.
The calculate function can return a value one of the two following ways:
1. A single latex text string
This will be rendered directly as a math expression in the white box for results.
2. A list consisting of of one or more dicts in the following format
{"type": type, "title": title, "content": content}
Where
type is the rendering type of the item, which currently can only have
"latex" as an accepted value
title is a string as title of the item that will show up above the math expression, and
content is the content of this item, which is usually the latext text
If a list is returned, the widget page will render its contents as a list of plain text title and math equation content pairs.