Jump to content
Sign in to follow this  
psla314

Array of Objects

Recommended Posts

Hi

 

Is it possible to create an array of objects in Delphi and then have that available in the Python Script ?

 

e.g. Where DataIn is pre defined in Delphi and added to the module using PythonModule.SetVar( 'DataIn', p );

 

x1 = DataIn[0].X

y1 = DataIn[0].Y

x2 = DataIn[1].X

y2 = DataIn[1].Y

 

I can get the following to work using 0 = X and 1 = Y and a DataInType : TPythonType

 

x1 := DataIn(0,0);

y1 := DataIn(0,1);

x2 := DataIn(1,0);

y2 := DataIn(1,1);

 

 

p := DataInType.CreateInstance;
Source := TPyDataList( PythonToDelphi(p) );
PythonModule.SetVar( 'Source', p );
PythonEngine.Py_DecRef(p);

 

But am having trouble getting the array operator to work in Delphi4Python

 

Is this even possible to use an array operator to call default index getters and setting like in Delphi ?

 

Regards

Peter

Share this post


Link to post

There are many ways to expose Delphi objects to Python but by far the easiest is to use WrapDelphi.   Please have a look at the WrapDelphi unit tests and Demo 31.

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×