[Pyobjc-dev] using PyObjCPointers (howto?)
Brought to you by:
ronaldoussoren
|
From: Scott H. <sc...@ya...> - 2008-01-30 22:33:52
|
I'm looking for an idiom by which I can use a given PyObjCPointer, that I get back from some Cocoa API, as a Carbon object (or pointer thereto). My specific requirement currently is to take a PyObjCPointer that I get back from a QTKit API, and use its referent as a Carbon.Qt.Media object. For example, I have a QTMedia object qtkMedia for which I need direct access to the media samples. In ObjC, [qtkMedia quickTimeMedia] produces a pointer to a QuickTime MediaType struct. In PyObjC, qtkMedia.quickTimeMedia() produces a PyObjCPointer. I would like to use the value of that pointer in using methods defined for class Carbon.Qt.Media. The naive thing is to say something like the following: qtkMedia = QTKit.QTMedia.alloc().initSomething() qtMedia = qtkMedia.quickTimeMedia() qtMedia.GetMediaSample But that raises an AttributeError: 'PyObjCPointer' object has no attribute 'GetMediaSample', whereas if qtMedia were a Carbon.Qt.Media object, I get something like "<built-in method GetMediaSample of _Qt.Media object at 0x26eb120>" Can I "cast" a PyObjCPointer like this to an instance of some Python class like Carbon.Qt.Media? As always, thanks in advance, Scott |