Using python4delphi component (win11+python3.8) in RAD Studio 11 (delphi11)

1. Download or directly clone the python4delphi component resources to the specified directory. I downloaded it to the Components folder and renamed the downloaded folder to (P4D). Renaming is not necessary.

Download address: https://github.com/pyscripter/python4delphi
Insert image description here

2.Installation

2.1 Go to the Install folder in the downloaded directory and double-click MultiInstaller.exe to install, as shown in the figure below

Insert image description here

2.1 Select the package that needs to be installed to install it, click next to continue, see the picture below

Insert image description here

2.2 Select the Components folder in step 1 and check it. Click next to start the installation, see the picture below

Insert image description here

2.3 The result after the installation is completed, see the picture below, click finish to complete the installation.

Insert image description here

3. Run the test to see if the installation is successful.

3.1 Open delphi11, select Components\P4D\Demos\Demo01\Demo01.dproj to open

Insert image description here

3.1 Select the PythonEngine control and modify the properties as follows:

Uncheck UseLastKnownVersion
Add DllPath path
Modify DllName name

Insert image description here

3.2 The modified result is as shown below:

Note here that it must be a 32-bit pythondll
Insert image description here

3.2 Add OnBeforeLoad event to PythonEngine control:

Insert image description here

Add the following content: PythonEngine1.SetPythonHome(PythonEngine1.DllPath);
Insert image description here

3.2 Start the program, make sure to select 32-bit, see the picture below

Insert image description here

3.2 After successful startup, as shown below, you can click Load script to load the python script file, or you can directly enter the code in the Memo below to run it.

Insert image description here

3.2 Directly enter the code running results in Memo

Insert image description here

3.3 At this point, the python4delphi component has been installed and run successfully.

Guess you like

Origin blog.csdn.net/Bluma/article/details/132207743