Loading
/custom-emojis/emojis/contour-map.png
Templates
📚
Articles & Resources
📖
Guides & Support
🌵
CalcTree
When you add a Python script as a source to a page, CalcTree is ready to connect that source to the rest of your page via Parameters. That means if you have parameters defined on your page content, you can use them instantly in your Python code.
Additionally, Python code variables can be taken as source parameters, making them instantly available on your page..

How-To

Use parameters from the page inside the Python code
When working in Python, type the name of the page parameter to use auto-completion. For example, if the page has a parameter called n, simply type 'n' in your Python code:
Using parameters defined on the page content inside Python

Click on the suggestion to use that page parameter in your Python code.

👉 Note that at the moment, you must click on that suggestion to use the parameter from the page content. Soon, our Python editor will recognise the page parameters by just typing or pasting their titles in your code without having to click on the auto-completion suggestion.

Use variables from Python code inside the page
After adding your code inside the code editor, you will notice that variables defined outside functions appear under the Python source on the Integrations pane. That means they have become source parameters, e.g:
Python variables appear as source parameters


🧐 Note that only variables defined at the global scope will be taken as source parameters. In other words, variables defined within a function won't be considered source parameters.

You can now drag and drop the source parameter into page:
Drag and drop source parameter on page content

You can alternatively insert source parameter factorial using the keyboard. For example, if the parameter is called factorial, you can insert it by typing the following: /pEnter faDown ArrowEnter.
Inserting a source parameter by keyboard


🙌 Bonus: if you don't want a Python variable to be taken as a parameter, start it with an underline, e.g. _i instead of i.

Now, your Python variables are mapped as parameters on CalcTree. They can be used on your page like any other parameter in your workspace. Read more about CalcTree parameters here.
You can even chain parameters from different sources to create multi-step calculations across Python, Spreadsheets and Mathematical expressions.




Still have more questions?

Join the conversation on Slack below!