> For the complete documentation index, see [llms.txt](https://calctree.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calctree.gitbook.io/docs/calculations/creating-calculations/python/adding-a-python-node.md).

# Adding a Python Node

Add a Python node to your page to create custom, script-based calculations using CalcTree’s built-in code editor.

### Getting Started

To add a Python source:

1. Open the **right-hand panel**
2. Click in the Nodes tab
3. **Click + and select Python**\
   \
   ![](https://94933883-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS1yC9mBIPsA0bB8PMGaq%2Fuploads%2Fk3FLZKOPijJOKDQtKX04%2Fimage.png?alt=media\&token=46a9bc32-ce44-4b02-b999-392fbc8c77f4)
4. Start coding\
   (A new code editor will appear at the bottom of your page with some initial helpful tips)&#x20;

<figure><img src="https://94933883-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS1yC9mBIPsA0bB8PMGaq%2Fuploads%2FR7SndDg8OZXmwQ0MszpB%2Fimage.png?alt=media&amp;token=03ca0231-c90d-4b7f-a140-798b36a6464f" alt=""><figcaption></figcaption></figure>

All code runs automatically once it is complete and has no errors.

### Python Editor Features

CalcTree’s built-in Python editor includes:

* Syntax highlighting
* Autocomplete and inline hints
* Real-time error reporting
* Keyboard shortcuts
* Find and replace

This editor is powered by Monaco Editor, the same technology used in Visual Studio Code.

### Editor Shortcuts (Windows / Mac)

{% tabs %}
{% tab title="Windows" %}

| Description         | keyboard shortcut        |
| ------------------- | ------------------------ |
| Undo                | Ctrl + Z                 |
| Redo                | Ctrl + Y                 |
| Cut                 | Ctrl + X                 |
| Copy                | Ctrl + C                 |
| Paste               | Ctrl + V                 |
| Toggle Line Comment | Ctrl + /                 |
| Search              | Ctrl + F                 |
| Replace             | Shift + Ctrl + F         |
| Increase indent     | Tab or Ctrl + ]          |
| Decrease indent     | Shift + Tab or Ctrl + \[ |
| Move a line up      | Alt + Up                 |
| Move a line down    | Alt + Down               |
| Select all          | Ctrl + A                 |
| Select to the end   | Alt + Shift + Right      |
| Select to the start | Alt + Shift + Left       |
| {% endtab %}        |                          |

{% tab title="MAC" %}

| Description         | keyboard shortcut           |
| ------------------- | --------------------------- |
| Undo                | Command + Z                 |
| Redo                | Shift + Command + Z         |
| Cut                 | Command + X                 |
| Copy                | Command + C                 |
| Paste               | Command + V                 |
| Toggle Line Comment | Command + /                 |
| Search              | Command + F                 |
| Replace             | Option + Command  + F       |
| Increase indent     | Tab or Command + ]          |
| Decrease indent     | Shift + Tab or Command + \[ |
| Move a line up      | Option + Up                 |
| Move a line down    | Option + Down               |
| Select all          | Command + A                 |
| Select to the end   | Command + Shift + Right     |
| Select to the start | Command + Shift + Left      |
| {% endtab %}        |                             |
| {% endtabs %}       |                             |

{% hint style="info" %}
CalcTree uses a Microsoft technology called Monaco Editor to provide the integrated Python editor. You can find more technical documentation about Monaco Editor [here](https://microsoft.github.io/monaco-editor/)
{% endhint %}
