The platform includes a unique set of features for Python integration:
On this page:
The .NET integration is currently compatible and tested with Python releases 3.7 - 3.11. While earlier and newer versions may work with most features, they are not officially tested or supported.
Setup Steps:
1. Install Python on the machines where you run the application and on those using the Solution Designer.
2. Configure the Solution Settings to select the appropriate Python shell folder.
Each solution can specify its own Python interpreter, facilitating the development and maintenance of different solutions that may require different Python versions.
You can download Python here. During the installation of the Python Engine, we strongly recommend choosing the option to “Install for all users”. Once you've downloaded, open command prompt and type “pip install pythonnet”. For this work, you'll need internet access. If internet is not available, download and install manually. Once Python .NET has been installed, you can then start using Python in your solution. |
Go to Solution → Settings tab and locate for the Python GroupBox. Click the "..." button, navigate to find the installed Python Engine, and select the python.exe file.
|
Once you've installed Python, you can take a look at our Python demo with code examples.
→ Learn more at Python Integration Demo.
Displays Code Behind and Graphical Elements
Graphical Elements and Actions: When defining the dynamic behavior of the graphical elements, the actions and the CodeBehind dynamics make asynchronous calls to server methods, which can be in Python.
# This code call the execution of the external file using Python Shell # with the optional args defined in this initial section # # The macro _ExecutionPath_ is replaced by the path where the solution is set to execute # Replace that macro by a specific path, or user other built-in macros as nedded # arg1 = @Tag.Tag1 arg2 = @Tag.Tag2 result = TK.ExecutePythonShell("_ExecutionPath_ExternalSum.py", [arg1, arg2]) @Tag.Result = result |
The code editor is accessed at the Designer Scripts → Code Editor page
When the editor is used to edit Script Tasks, you can test the scripts directly, using the Play button at the Task name line. The results of your code will show in the standard Designer output.
The access to tags and other properties for other models is exactly the same as C# or VB.Net; just use the '@' symbol to access the properties directly, as shown in the image: '@tag.Tag1'.
At the Script namespace or in any code in your solution, call methods defined in the script classes.
@Script.Class.TestClass.ExempleMethod(param1, param2) |
This activation is independent of the language the class was created in. This means C# and VB.NET can call Python classes, and Python code can call .NET classes.
In this section: