From: Bob H. <bh...@co...> - 2011-08-04 14:24:04
|
Thanks for the feedback, Alex. I just realized that I can't get around this. I have a level of indirection that prevents me from getting at the correct 'self' context in an automated way. The class instance I need ('my_class') cannot be implicitly inferred from the 'ui.setevent' method call, so I'll have to pass it in explicitly regardless. So, ignore my question. It was ignorant. ;) On 8/4/2011 7:14 AM, Alex Pyattaev wrote: > Yes, but the thing is that Self is a Python object which is created AFTER your > class constructor is called, so constructor has no idea... You could set it > separately though and then refer to it in methods. > > On Wednesday 03 August 2011 14:17:58 Bob Hood wrote: >> I'm implementing Python callbacks in my C++ code. I have it working, but it >> requires the call to include the 'self' value as an argument. For example, >> a call somewhere in my_class: >> >> class my_class(object): >> [...] >> ui.setevent(drag_control, self, 'drag_callback', None) >> >> will map a callback to: >> >> class my_class(object): >> [...] >> def drag_control(self, data): >> [...] >> >> My question: Is there a way to have SWIG pass the current 'self' context >> through the wrapper code to the C++ function so I don't have to require it >> from the user? |