|
|
|
|
|
- Overview
- How to proceed?
- Importing the ".py" file
- Using Python functions in WLanguage code
- Caution
WLanguage allows for native Python calls. The principle is simple: - Import the ".py" file into the WINDEV project.
- In the WLanguage code:
- Load the Python DLL.
- Call Python functions.
Note: You can also execute Python functions directly from WLanguage. For more details, see Python: Using WLanguage. Importing the ".py" file Importing the ".py" file into the environment allows for the automatic recognition of all the functions of the ".py" script. Each script function is then considered a native WLanguage function.. To import the ".py" file: - Set up a Python interpreter. This interpreter will read the information contained in the ".py" file.
- On the "Home" tab, in the "Environment" group, expand "Options" and select "WINDEV/WEBDEV general options".
- Go to the "Directories" tab and enter the path of the interpreter (python*.dll file) in "Python interpreter".
Note: This Python version may be different from the one used at runtime.. However, it must be compatible with Python 3.9, the reference Python ABI used in WINDEV and WEBDEV. The Python interpreter must be the same architecture as WINDEV or WEBDEV (32 or 64-bit). - Validate the configuration window.
- Import the ".py" files via the "Project explorer" pane using one of the following methods:
- Open the context menu of "External descriptions" and select "Import a Python module into this project". Select the file that corresponds to the module and validate.
Note: It is possible to import all Python modules in a directory using the "Import all Python modules in a directory into this project" option. - Open the context menu of "Other" and select "Add elements". Select the file that corresponds to the module and validate.
- Drag the ".py" file from the Windows explorer and drop it onto the "Project explorer" pane.
- The Python file is in the project folder, and the module (with its functions) will appear in the "Project explorer" pane, in the "External descriptions" folder.
Remark: When developing the application, it is also necessary to indicate the path of the Python libraries used in the current project configuration: - In the "Project Explorer" pane, display the context menu for the "Configurations" option and select "Description".
- On the "Components" tab, specify the external Python libraries.
Using Python functions in WLanguage code To use Python functions in WLanguage code: - Initialize the Python engine using PythonInitialize. This function defines the Python interpreter used for the execution. You can use an interpreter different from the one used for the import, but it must be compatible with Python ABI 3.9.
- Enter the name of the Python function to execute, with its parameters if necessary.
Please note: not all parameter passing types are supported.. The default values of the parameters are not taken into account. Parameters are passed by value only. In addition, only the following types can be used to pass parameters, and for the return value:- Boolean,
- Integer (signed or unsigned),
- Real,
- Character string.
Caution - The ".py" modules must be accessible on disk, in the folder of the deployed executable, or in the location specified with PythonAddPath. The ".py" modules cannot be found if they are embedded in the executable library.
- Python is case-sensitive. The module and function names must be written using correct upper and lower case characters.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|