PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 28 → Usar python code en windev
Usar python code en windev
Iniciado por Walter Louis, out., 07 2020 2:13 AM - 2 respostas
Publicado em outubro, 07 2020 - 2:13 AM
Tengo una aplicación donde quiero usar codigo PYTHON para unas tareas específicas de matemática simbolica.
No encuentro información que me podrá ayudar. Alguien me puede dar un empujon con algun ejemplo, Gracias
Publicado em fevereiro, 27 2023 - 10:25 PM
Download python embeddable https://www.python.org/downloads/windows/

Unzip into windev exe dir
Create script.py

lines = ['Readme', 'How to write text files in Python']
with open('readme.txt', 'w') as f:
    for line in lines:
        f.write(line)
        f.write('\n')


On windev
ExeRun("python script.py",exeIconize,exeWait)
sRes is string = fLoadText("readme.txt")
Info(sres)
Publicado em fevereiro, 28 2023 - 11:10 AM
To use Python code in a WinDev application, you can use the Python for Windows extensions (pywin32) library, which provides a way to call Python functions from a Win32 application. Here is an example of how you can do this:

Install Python and pywin32 on your computer.
In your WinDev application, create a button or other control that will trigger the Python code.
In the button's click event, use the PyWin32 library to execute the Python code. For example:
PROCEDURE Button1Click()
    sPythonCode is string = "import math; x = math.sin(1)"
    Python = iPythonCreate("Python.Test")
    iPythonExec(Python, sPythonCode)
    iPythonRelease(Python)
END


In this example, we import the math module and use it to calculate the sine of 1. The iPythonCreate function creates a new Python interpreter, and iPythonExec executes the code in that interpreter. Finally, we release the interpreter with iPythonRelease.

Note that you will need to adjust the code to fit your specific use case, including the name of the Python module and any additional Python code you want to execute.

Also, keep in mind that using Python code in a WinDev application may have performance implications and may require additional setup and configuration.
You can also visit:
[code:xml]
https://www.igmguru.com/machine-learning-ai/rpa-automation-anywhere-training/

[/code]