PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WINDEV and WEBDEV 27 feature!
  • Overview
  • Caution
  • Code example
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
Overview
WLanguage supports Python functions in native mode (for more details, see Python: Native calls). You can also execute Python functions via WLanguage functions.
Several functions are available:
Versions 27 and later
PythonAddPath
New in version 27
PythonAddPath
PythonAddPath
Adds the path to a directory or the path to the virtual environment to search for Python modules.
Versions 27 and later
PythonExecute
New in version 27
PythonExecute
PythonExecute
Executes a function present in a Python module.
Versions 27 and later
PythonInitialize
New in version 27
PythonInitialize
PythonInitialize
Specifies the location of the Python DLL to be loaded.
Versions 27 and later
PythonTerminate
New in version 27
PythonTerminate
PythonTerminate
Unloads the Python DLL and frees memory.

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.
Code example
// Initialize the Python interpreter
PythonInitialize(PYTHON_INSTALL_PATH + "\Python39\python3.dll")
// Declare the import paths of the modules used
PythonAddPath("D:\source.test\pythonProject\venv\Lib\site-packages")
PythonAddPath("D:\source.test\pythonProject")
// Solve 5x³+x²-3x+2=0
sEquation is string = "5*x**3+x**2-3*x+2"
sListRoot is string = PythonExécute("main", "solver", sEquation)
nNbRoot is int = StringCount(sListRoot, ",") + 1
Trace("The ""[%sEquation%]"" equation admits [%nNbRoot%] roots:")
FOR n = 1 _TO_ nNbRoot
Trace("r[%n%] = [%ExtractString(sListRoot, n, "", "")%]")
END
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/
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment