1

Hi i'm using a boost python. There is an python object which was made by my c++ class.

like

python::class_<RectObject> Embedded_RectObject("RectObject");
Embedded_RectObject.def(init<RectObject>(int,int,int,int));
Embedded_RectObject.def_readwrite(TopX, &RectObject.TopX);

And i create that object at run time in python.

RectData = RectObject(10,10,10,10);

Now i want to register(add) below python method to 'RectData' which is python side object.

#return my member which name is TopX
def GetTopX():
    return self.TopX

I want to register when it is a runtime. My system that user can access by python script. my system will support all available functions or class to users. And the system must support the user's custom method to object, so i need register python method to object at runtime.

(I want to do this c++ side code that register python method to python object at run time registration. Because my system will read user's custom python script files and register it to python object (EX: RectObject) )

How should i do it?

summation
  • 142
  • 1
  • 8
  • Does this answer help? https://stackoverflow.com/questions/972/adding-a-method-to-an-existing-object-instance – Jacques Kvam Mar 27 '18 at 05:18
  • @JacquesKvam Thanks for answering but i want c++ side solution for register method to python object. Because my system is run with c++ so it will read all user's script files and register to each object instances. – summation Mar 27 '18 at 11:28

0 Answers0