Python script interfaces
- Last UpdatedOct 29, 2026
- 1 minute read
Note: Syntax errors are flagged during development (see Python editor IntelliSense and script checking for more information), but logic and programming errors are not caught during development. If a Python script has an error during runtime, the script will terminate and the Python Script task will log a Python exception, but only if you enable Python logging. For this reason, we recommend that you enable Python logging.
You can create scripts using Python libraries, HMI Python functions, and tags from the tags database. The interfaces that support Python scripting currently are Global Procedures and Background Tasks Script worksheets. Here is a summary of the Python scripting interfaces:
|
Interface |
Scope for Procedures and Variables |
Execution |
Functionality |
|---|---|---|---|
|
Global Procedures |
All Script Sheets from Tasks |
- |
Declaration of Variables, Classes, and Procedures |
|
Startup Script |
All Script Sheets from Tasks |
Server (BGTask) |
Declaration of Variables, Classes, and Procedures Execution |
|
Script Sheets/Groups |
That Script Sheet/Group only |
Server (BGTask) |
Declaration of Variables, Classes, and Procedures Execution |
When the application starts or whenever the PythonScript task starts again after that, the Python code in the Global Procedures and the Background Tasks Startup Script is executed in this order: Global Main Procedures, other Global Procedures in alphabetical order, and then the Tasks Startup Script. Any other Tasks Script sheets will be executed, when enabled, in numerical order. Whenever changes are made to a Python interface, the PythonScript task will restart.
When writing your code in a Python scripting interface, you can access any tag from the tags database using the proprietary functions HMI.ForceTagChange(), HMI.GetTagValue(), and HMI.SetTagValue(). See HMI Python module for more information.