【发布时间】:2012-08-26 16:15:36
【问题描述】:
当我在我的 pyObjC 代码中调用 setDelegate_ 时,我得到一个 AttributeError: 'tuple' object has no attribute 'setDelegate_'。
我的代码如下所示:
def createMovie(self):
attribs = NSMutableDictionary.dictionary()
attribs['QTMovieFileNameAttribute'] = '<My Filename>'
movie = QTMovie.alloc().initWithAttributes_error_(attribs, objc.nil)
movie.setDelegate_(self)
编辑
我发现我不能对电影对象使用任何实例方法。
【问题讨论】:
-
QTMovie.alloc().initWithAttributes_error_(attribs, objc.nil)返回什么?一个元组 (QTMovie,error) ? -
实际上它返回的是这样的:
(<QTMovie: 0x7f840d875d30 time scale = 1000, duration = 8553387, rate = 0.000000, tracks = { 0x7f840c8c2240 0x7f840c81fa00 0x7f840ce0be50 0x7f840cf764b0 0x7f840b444590 0x7f840b42d6e0 0x7f840d40ed10 0x7f840cd31290 0x7f840c8d1b40 }>, None). -
在 Objective-C 中我认为上面的代码应该可以完美运行。
-
不幸的是,您不是直接使用 Objective-C,而是使用接口。期待惊喜......
标签: python delegates quicktime pyobjc qtkit