9.63.3 Python Code Editor Assistance

In the code area of the Python Module, the General tab of the Python collection and processing agents, and the API tab of the Python Connector agent, the different parts of the code are color coded according to type, for easier identification. When you right-click in the code area, a context sensitive popup menu appears, enabling easy access to the most common actions that you might want to perform. Code completion provides proposals when requested to help you write Python code. In addition, to make it easier to navigate in a Python code configuration, there is an Outline navigation panel to the right of the code area. These features are described below.


Syntax Highlighting

The text is color coded according to the following definitions:

Brown  - Strings

Blue  - Functions

Green  - Types

Purple  - Keywords

Orange - Comments

Right-Click Menu

The right-click menu has the following options:

Text Editor right-click menu


Option
Description
Font Size

Sets the font size.

Cut

Moves the selected text to the clipboard.

You can also press the CTRL+X keys to perform this action.

Copy

Copies the selected text to the clipboard.

You can also press the CTRL+C keys to perform this action.

Paste

Pastes the contents of the clipboard into the place where the insertion point has been set.

You can also press the CTRL+V keys to perform this action.

Select All

Selects all the text.

You can also press the CTRL+A keys to perform this action.

Undo

Undoes your last action.

You can also press the CTRL+Z keys to perform this action.

Redo

Redoes the last action that you undid with Undo.

You can also press the CTRL+Y keys to perform this action.

Find/Replace...

Displays a dialog where chosen text may be searched for and, optionally, replaced.

You can also press the CTRL+H keys to perform this action.

Find/Replace dialog

Quick Find

Searches the code for the highlighted text.

You can also press the CTRL+F keys to perform this action.

Find Again

Repeats the search for the last text entered in the Find/Replace dialog.

You can also press the CTRL+G keys to perform this action.

Go to Line...

Opens the Go to Line dialog where you can enter which line in the code you want to go to. Click OK and you will be redirected to the entered line.

You can also press the CTRL+L keys to perform this action.

Toggle Line Numbers

Adds or removes the line numbering.

You can also press the CTRL+F2 keys to perform this action.

UDR Assistance...

Opens the UDR Internal Format Browser from which the UDR Fields may be inserted into the code area.

You can also press the CTRL+U keys to perform this action.

Import...

Imports the contents from an external text file into the editor. Note that the file must reside on the host where the client is running.

Export...

Exports the current contents into a new file, for instance, to allow editing in another text editor or usage in another system.

Code Completion

Performs code completion on the current line. For more information about Code Completion, see the section below, Code Completion.

You can also press the CTRL+SPACE keys to perform this action.

Jump to Pair

Moves the cursor to the matching parenthesis or bracket.

You can also press the CTRL+SHIFT+P keys to perform this action.

Toggle Comments

Adds or removes comment characters at the beginning of the current line or selection.

You can also press the CTRL+3 keys to perform this action.

Surround With

Adds a code template that surrounds the current line or selection:

for Loop (CTRL+ALT+F)
while Loop ( CTRL+ALT+W )
Debug Expression ( CTRL+ALT+D )
if Condition ( CTRL+ALT+I )
Block Comment ( CTRL+ALT+B )

Code Completion

To make Python coding easier, the Code Completion feature provides you with context-sensitive proposals.

To access Code Completion, place the cursor where you want to add code, press CTRL+SPACE, select the correct proposal and click Enter. In order to reduce the number of hits, type the initial characters of the element that you are looking for. The characters to the left of the cursor will be used as a filter.

To be provided with context-sensitive proposals from the Python packages that you have installed, you must configure and run the Python Language Service tool while you create workflows with Python agents. To open the Python Language Service, click the Tools button in the upper left part of the Desktop window, and then select Python Language Service. For further information, see 9.50.4 Python Language Service.

When running the Python Language Service, Code Completion covers:

  • classes
  • functions
  • variables
  • modules
  • udrs
  • fields
  • function blocks
  • keywords
  • code snippets
  • documentation

For further information, see 9.50.5 Python Writer's Guide.

Note!

You can use Code Completion without running the Python Language Service, but this provides limited context-sensitive proposals.

Python Code Editor Outline

The Python Code Editor Outline provides a view of all the blocks, variables and functions in a Python code configuration and makes it possible to easily navigate between different types in the Python code. The entries in the navigation panel are automatically updated as you make valid entries in the Python code area.

You can also filter what you want to display in the Outline navigation panel. You can search for a specific block, variable or function using the free text field, or by selecting one of the quick filter buttons for different types:

b

Click to display or hide the function blocks within the Python code configuration displayed in the code area.

v

Click to display or hide the variables within the Python code configuration displayed in the code area.

m

Click to display or hide the functions within the Python code configuration displayed in the code area.

The Outline navigation panel can be hidden or visible. By default, it is visible and all the elements are displayed. To hide or display the navigation panel, click the vertical Outline button to the right of the code area.

Python Code Editor Outline navigation panel