[Delphi] How to Use python for Delphi

Source: Internet
Author: User

Python for Delphi builds a bridge between Delphi and the powerful scripting language python, which is very convenient to use. It enables Delphi's gorgeous interface to work with Python's powerful, concise, and stable background logic processing capabilities, it makes the application module clear, the interface is beautiful, and the complex logic in the background is no longer complicated, greatly improving the development efficiency. Some problems that are easy to ignore occur during usage are summarized as follows.

Version

Python for Delphi supports Python 2.3, and the latest and most stable python is 2.4. When using python for Delphi, the system prompts that the python23.dll cannot be found. Follow these steps:

Set the tpythonengine attribute. Set dllname to python24.dll and regversion to 2.4. The most important thing is that uselastknownversion is set to false. Otherwise, dllname and regversion do not work.

 

Onpathinitialization

Onpathinitialization is an event called when tpythonengine sets the python path, but sometimes it is not called. Why?

When tpythonengine is initialized, it first finds whether there is any corresponding path setting information in the registry. If yes, it reads the information directly from the Registry without executing onpathinitialization. For example, tpythonengine's regversion is 2.4, it goes to the Registry to check whether there is [HKEY_LOCAL_MACHINE/software/Python/pythoncore/2.4/pythonpath]. If there is direct reading, it does not call onpathinitialization, in onpathinitialization, you can set the python library path through the program. After the setting is successful, it will be written to the Registry.

 

Distribution

1. Install the entire standard Python module and library, that is, the lib directory.

2. Install Python standard modules in the entire DLLs directory selectively.

3. Install python24.dll to the system directory, such as C:/winnt/system32.

4. In the self-written Delphi Program, use the onpathinitialization event of tpythonengine to set the path of LIB and DLLs, and add the directory of the Self-compiled module to the path.

Note: Each path must be separated by a semicolon (';').

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.