ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Python functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Specifies the location of the Python DLL to be loaded.
Example
sPythonModule is string
<IF ExecutionTarget=Windows>
// Example of a Python module location
// The name of the Python module can be different
sPythonModule = SysDir(srLocalAppData) + ..
[fSep]+"Programs\Python\Python39\python39.dll"
<ELSE>
<IF ExecutionTarget=Linux>
// Example of a Python module location
// The name of the Python module can be different
// (depends on the version of Python, the Linux distribution)
sPythonModule ="/usr/bin/python/python39.so"
<END>
<END>
IF NOT PythonInitialize(sPythonModule) THEN
// In this case, you must:
// Check the path
// Check that the compilation mode (32/64-bit) matches the runtime mode
Error("Python initialization error", ErrorInfo())
RETURN
END
Info(HelloWorldImportedPythonFunction())
// With an imported Python file (.py) in the project that contains:
// def HelloWorldImportedPythonFunction():
//    return "Hello World!";
 
IF NOT PythonAddPath(fDataDir()) THEN
Error("Unable to initialize Python path", ErrorInfo())
RETURN
END
// "python_file.py" must be in the directory
// specified by PythonAddPath.
// In this example, this directory is the data directory
Info(PythonExecute("python_file", "HelloWorldPythonFunctionNotImported"))
 
PythonTerminate()
Syntax
<Result> = PythonInitialize(<DLL location>)
<Result>: Boolean
  • True if loaded successfully,
  • False otherwise.
<DLL location>: Character string
Full or relative path of the Python DLL to be loaded.
Remarks
  • The Python DLL must be the same architecture as the application. For example, if the application is executed in 32-bit mode, a 32-bit DLL must be used.
  • The version of the DLL is important: The Python ABI may change from one version of Python to the other (see the Python documentation). A Python interface compatible with Python 3.9 must be used.
  • Error handling:
    If there is a problem during loading, a fatal error is thrown: version not supported, internal Python error, etc.
Related Examples:
WD Python 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
Component: wd290vm.dll
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help