Python scripts (script groups)
- Last UpdatedOct 29, 2026
- 3 minute read
A Python Script worksheet, also called a Script Group, is used to implement program logic (using Python) that is executed during runtime.
To create a new Script worksheet:
Choose one of these options to create and open a new scripting worksheet for editing:
-
On the ribbon Insert tab Task Worksheets group, select Script, then choose the type of sheet on the menu: VBScript or Python.
-
In the Tasks tab of the Project Explorer, open the Script folder to access the VBScript and Python subfolders. Right-click the appropriate Script subfolder, VBScript or Python, and choose Insert on the context menu.
A new Script worksheet opens in the Screen/Worksheet Editor.

To edit and save a Script worksheet:
-
In the Tasks tab of the Project Explorer, open the Script folder to access the VBScript and Python subfolders. Open the appropriate Script subfolder, VBScript or Python, and either double-click the script or right-click it and choose Open on the context menu. The script worksheet is opened in the Screen/Worksheet Editor.
-
Enter your code in the interface. For example:
temperature_fahrenheit = HMI.GetTagValue("Temp1_F")
temperature_celsius = fahrenheit_to_celsius(temperature_fahrenheit)
HMI.SetTagValue("Temp1_C", temperature_celsius)
-
Save your changes. If saving a new Script worksheet, you will be prompted for a Sheet Number.

The displayed name of the new worksheet uses the Sheet number of the worksheet, for example 1, followed by a colon and then the string entered in the Description field, if any; for example Temperature Script.

Note: When a Tasks script worksheet or a Global Procedures script worksheet is saved during runtime (on-line configuration), the Startup Script will be executed again and the values of the local variables of any script worksheet will be reset.
Script worksheet features and considerations
-
The code configured in each script worksheet is executed by the Background Task module. The project scans the worksheets sequentially (based on the worksheet number).
-
Only the scripts/script groups in which the condition configured in the Execution field of the worksheet is TRUE (non-zero) are executed.
Note: The Execution field only supports syntax supported by the Built-in Scripting Language. Only the body of the worksheet supports another scripting language (Python or VBScript).
-
The Description field accepts a string value. This value will appear in the name of script worksheet in the Project Explorer.
-
Variables, classes, and procedures declared in the worksheet have local scope for that specific worksheet/group only, unless declared global. By default, they are not available for other worksheets or interfaces.
-
You can define procedures in the script worksheet, and you can call procedures defined in the Python Global Procedures or in the Python Startup Script.
-
You can put a password on any of your scripting worksheets to prevent them from being edited or analyzed by other users. See Password-protecting files for more information.