AlexanderMi 0 Posted April 24 I have delphi object and wrapped class to use in python. TEventFromScript = class(TInterfacedObject, IEventFromScript) strict private FData: string; function GetData: string; procedure SetData(const AValue: string); public property Data: string read GetData write SetData; end; TPyEventFromScript = class(TPyDelphiObject) private // Getter function Get_Data(AContext: Pointer): PPyObject; cdecl; // Setter function Set_Data(AValue: PPyObject; AContext: Pointer): Integer; cdecl; function GetDelphiObject: TEventFromScript; procedure SetDelphiObject(const Value: TEventFromScript); public constructor CreateWith(APythonType: TPythonType; args, kwds: PPyObject); override; class function DelphiObjectClass: TClass; override; class procedure RegisterGetSets(PythonType: TPythonType); override; // Properties property DelphiObject: TEventFromScript read GetDelphiObject write SetDelphiObject; end; I can use in python wrapped TPyEventFromScript and it is ok. I can use TventFromScript in delphi. But... at some point I need pass TEventFromScript instance to python. How I can somwhow convert it to TPyEventFromScript? e.g. on delphiI have TQueue<TEventFromScript > and on python side I have a function who returns dequeued TEventFromScript, I need tell to python that it now responsible for returned object... convert TEventFromScript to TPyEventFromScript and forget. Share this post Link to post
pyscripter 689 Posted April 24 (edited) See TPyDelphiWrapper.Wrap(AObj: TObject; AOwnership: TObjectOwnership): PPyObject; Also you do need need your TPyEventFromScript. This is the old and hard way. You can use instead (e.g. in your FormCreate): PyDelphiWrapper1.RegisterDelphiWrapper(TPyClassWrapper<TEventFromScript>).Initialize; Since you are using interfaces there is also: function TPyDelphiWrapper.WrapInterface(const IValue: TValue): PPyObject; Edited April 24 by pyscripter Share this post Link to post