|
|
|
|
|
PythonExecute (Function) In french: PythonExecute Executes a function present in a Python module. sPythonModule is string
<IF ExecutionTarget=Windows>
sPythonModule = SysDir(srLocalAppData) + ..
[fSep]+"Programs\Python\Python39\python39.dll"
<ELSE>
<IF ExecutionTarget=Linux>
sPythonModule ="/usr/bin/python/python39.so"
<END>
<END>
IF NOT PythonInitialize(sPythonModule) THEN
Error("Python initialization error", ErrorInfo())
RETURN
END
Info(HelloWorldImportedPythonFunction())
IF NOT PythonAddPath(fDataDir()) THEN
Error("Unable to initialize Python path", ErrorInfo())
RETURN
END
Info(PythonExecute("python_file", "HelloWorldPythonFunctionNotImported"))
PythonTerminate()
Syntax
<Result> = PythonExecute(<Module> , <Function> [, <Parameter 1> [... [, <Parameter N>]]])
<Result>: Variant Value returned by the executed Python function (possibly empty). <Module>: Character string Name of the Python module to be loaded. See the Python documentation for more details. Caution: The name of the module is "case-sensitive". <Function>: Character string Name of the Python function to be executed. This function can be found in <Module>. Caution: The name of the function is "case-sensitive". <Parameter 1>: Type of parameter First parameter to be passed to the Python function. <Parameter N>: Type of parameter Last parameter to be passed to the Python function. Remarks - The Python interpreter must have been configured beforehand (via PythonInitialize).
- Only the following simple types can be used for the return value and for the different parameters of the Python function:
- Boolean
- Integer (signed or unsigned)
- Real
- Character string.
- The Python module must be in the runtime directory. Otherwise, use PythonAddPath to specify the paths to be taken into account.
- An error message is displayed in the following cases: interpreter not loaded, incorrect parameter type, etc.
- When PythonExecute is called,
- the strings passed as arguments are encoded in UTF-8.
- the string returned by a function from the module in a variable of type variant is not automatically decoded. You must use UTF8ToString.
Related Examples:
|
Training (WINDEV): WD Python
[ + ] This example shows how to run Python code in WINDEV applications. Prerequisite: Python 3 must be installed on the computer. To get Python 3, go to http://legacy.python.org/download/
|
Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|