- Price
- 12.50
- Quantity
- 4 → 6
- Total
- 50 → 75
Describe a dependency once.
A registration estimate depends on a price and a quantity. A formula listens to those two values and writes a result. A summary then reads the result through an ordinary binding.
You can move the summary to another part of the page without moving the calculation. You can also reuse the total in a second calculation, such as a gross estimate.
Inputs, expression, destination.
This short Python declaration contains an inline JavaScript expression. Both caret arguments trigger recalculation; result_path is represented by the first positional argument. _init=True computes the initial value as the page starts.
For reusable calculations, use a named method of Logic through func. This small arithmetic example teaches the dependency itself. Financial rules and exact rounding still need to be chosen deliberately for a real quotation.
pane.dataFormula(
".total", "price * quantity",
price="^.price", quantity="^.quantity",
_init=True
)Read the explanation here. The working lesson and full contract are linked below.
When a calculation becomes an action.
A formula produces a value. A controller performs behavior: responding to a button, reacting to a change or preparing an operation. Keeping those purposes distinct makes the page easier to read.
Our estimate is now responsive, but responsive does not mean valid. Next we look at what should happen when someone leaves the name blank.
Change one answer
The quantity becomes 6 and the price stays 12.50. What happens?
Reveal the explanation
The formula runs because quantity is reactive. The result becomes 75, and any bound summary follows it.
Try the working example and read the full contract
KEEP EXPLORING