2012-04-23 36 views
1

我想使用GdkPixbuf.Pixbuf.new_from_data(),如gtk 2.x所示,我传递7个参数。但它给了我一个错误,我需要传递9个参数。GdkPixbuf.PixbufDestroyNotify - NotImplementedError - python gtk3

我现在正在为gtk2.x工作。所以我想出了另外两个我需要通过的论点。

http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-creating.html

http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-refcounting.html#GdkPixbufDestroyNotify

其中一个参数是类型GdkPixbuf.PixbufDestroyNotify的。我不知道该怎么做。

我正在尝试帮助(GdkPixbuf.PixbufDestroyNotfiy)在ipython中,但我得到一个错误。

错误:NotImplementedError。

self.img_pixbuf = GdkPixbuf.Pixbuf.new_from_data(self.img.tostring(), 
               GdkPixbuf.Colorspace.RGB, 
               False, 
               self.img.depth, 
               self.img.width, 
               self.img.height, 
               self.img.width*self.img.nChannels) 

#Here my self.img is cv2.cv.iplimage object (OpenCV iplimage) 

我收到以下错误:

/home/jay/<ipython console> in <module>() 

/usr/lib/python2.7/dist-packages/gi/module.pyc in __getattr__(self, name) 
    241     return registry[key] 
    242 
--> 243   return getattr(self._introspection_module, name) 
    244 
    245  def __dir__ (self): 

/usr/lib/python2.7/dist-packages/gi/module.pyc in __getattr__(self, name) 
    189    wrapper = info.get_value() 
    190   else: 
--> 191    raise NotImplementedError(info) 
    192 
    193   self.__dict__[name] = wrapper 

NotImplementedError: <gi.CallbackInfo object (PixbufDestroyNotify) at 0x0x8df5b6c> 

什么能在这里是什么问题?

回答

1

在PyGObject中,您不必处理DestroyNotify函数。如果有一个暴露在API中,那么这是一个错误。您应该将其报告给bugzilla.gnome.org

+0

您确定这是一个错误?我在这里没有做错什么?无论如何报告错误。 https://bugzilla.gnome.org/show_bug.cgi?id=674691 – Froyo 2012-04-24 05:21:18

+0

从错误报告看来,开发人员称这不易修复,但他提出了解决方法。 – ptomato 2012-04-24 19:21:38

+0

我知道这是一个错误,因为在C中需要使用DestroyNotify函数进行内存管理。但是,在PyGObject中,内存管理应该自动处理。 DestroyNotify函数应该在幕后自动提供,并且不在Python API中公开。它不是,所以API被破坏了。 – ptomato 2012-04-24 19:24:17

相关问题