CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • Getting Started
  • Python Editor Features
  • Editor Shortcuts (Windows / Mac)
  1. Calculations
  2. Integrations
  3. Python in CalcTree

Adding a Python Source

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

PreviousPython in CalcTreeNextDefining Parameters in Python

Last updated 1 day ago

Getting Started

To add a Python source:

  1. Open the right-hand Integrations panel

  2. Click Code (If you already have one or more sources integrated to the page, just click "+ Add")

  1. Start coding (A new code editor will appear at the bottom of your page with some initial helpful tips)

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)

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

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

CalcTree uses a Microsoft technology called Monaco Editor to provide the integrated Python editor. You can find more technical documentation about Monaco Editor

here