ERACS Python Editor

ERACS provides its own Python Editor which you can use to create your Python scripts. The benefits of using the ERACS Python Editor over other text editors are that it has built-in features specifically for using the ERACS Python Interface, such as support for using the virtual environment in which the Interface may be installed, direct access to example scripts which demonstrate how to use the ERACS Python Interface and a terminal with direct access to Python for executing code directly.

_images/Editor.png

ERACS Python Editor GUI

Features

  • Linting - The Editor will highlight lines with errors, warnings, refactorings, and convention recommendations. It does this in the background so the main Editor window continues running without delay.

  • Syntax highlighting - Code syntax will be highlighted in various colours to make it easy to distinguish what each line of code does. For example, conditional statements are highlighted a specific colour to easily identify if..elif..else blocks.

  • Terminal - Use the Terminal to execute Python code directly. The Terminal keeps a history of entered commands which can be accessed using the up and down arrow keys. Use the Terminal history to quickly re-enter commands.

  • Tabs - Have multiple scripts open in different tabs for easy editing and executing.

  • Styling - Style the Editor to look how you want with the ability to easily change font styles, syntax highlighting colours, and linting colours.

  • Drag & Drop - Drag files into the Editor to quickly open files for editing.

  • Environment Support - Built-in support for a virtual environment residing in the Python folder of the ERACS installation (typically in C:\Program Files (x86)\ERACS\Python\). The virtual environment contains a minimal Python setup with the ERACS Python Interface pre-installed. Use the virtual environment by selecting it from the list of installed Python versions in the Program Options window of the Python Editor, accessible via the Tools menu. The virtual environment can be installed and configured with the ERACS Python Interface Setup Wizard.

Recommendations

  • Monospaced typefaces - It’s recommended to use monospaced fonts such as Courier New or Consolas in the editor. Monospaced fonts comprise fixed-width characters and are therefore often used in scripting editors to make line lengths consistent and make the code easier to read.

Terminal

The Terminal is a simplified way of running Python code. Entering into the Terminal print("test") will output ‘test’ as expected.

State is saved between Terminal commands like a normal Python terminal, so setting a variable and using it later will work.

The Terminal and the scripts loaded inside the Editor do not use the same Python engine, so variables stored in the Terminal are not accessible when executing scripts in the Editor and vice versa.

The default working directory for the Terminal is the default location for Python Scripts for ERACS (see Python Scripts folder for more details). The default location for Python Scripts is the Python Scripts folder in the ERACS Projects folder in the Documents area.