Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Ultra-Fast Way To Wrap Delphi Objects To Python Objects With Python4Delphi Sample App

How to wrap the existing or new Delphi Objects into Python Objects? Not sure? Python4Delphi has the flexibility to do that using a TPyDelphiWrapper component. This post will guide you on how to wrap a Delphi Object to a python Object. You can also use Python4Delphi with C++Builder.

Python4Delphi Demo32 Sample App shows how to wrap a Delphi Object to Python Object with some Examples as listed. You can find the Demo32 source on GitHub.

Prerequisites: Download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out this video Getting started with Python4Delphi.

Components used in Python4Delphi Demo32 App:

You can find the Python4Delphi Demo32 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo32.dproj. Open this project in RAD Studio 10.4.1 and run the application.

Implementation Details:

A Delphi class TPoint is created, which is wrapped by a wrapper class TPyPoint The PyDephiWrapper initialize the TPyPoint by below procedure.

[crayon-6742cc88085ba692669106/]

In this sample, On clicking Execute button, it is wrapped to Python Object using the following code.

[crayon-6742cc88085c1430567149/]

Followed by wrapping the TPoint, the below memo1 Python scripts demonstrate the type and representation.

[crayon-6742cc88085c3095536476/]
<strong>Python4Delphi Demo32<strong>

Exit mobile version