GNOME Bugzilla – Bug 489571
ctypes interop
Last modified: 2012-04-20 09:09:31 UTC
To make life easier for users that find their favorite API left out of python bindings, it would be dramatically useful to have two ctypes interop features: - Constructors for all GObject's and GBoxed's (possibly other types) should accept a ctypes.c_void_p and just create a proxy for that and return it. - All objects should have a method, get_c_void_p or whatever, that returns ctypes.c_void_p pointers of the underlying C object. Thanks.
Humm, seems like id(obj) should return the C pointer address. Not sure if pygtk does that.
Behdad: You can use hash() on GObjects to get the C pointer address. id(obj) gets the a pointer address, but of the python wrapper object and not the original "C" structure.
(In reply to comment #2) > Behdad: You can use hash() on GObjects to get the C pointer address. Except that for example I asked you and you changed hash(pango.FontDescription()) to return pango_font_description_hash(). That is, there's no guarantee that has() returns the C pointer address, right? > id(obj) gets the a pointer address, but of the python wrapper object and not > the original "C" structure. Right, found that out...
FWIW, this is what one ends up doing if they don't have proper support for these things: http://cairographics.org//freetypepython
Thanks for taking the time to report this bug. However, this bug report applies to a PyGObject version that is too old and not supported anymore. PyGObject developers are no longer working on static bindings, so unfortunately there will not be any bug fixes for the version this report applies to. By upgrading to a newer version of PyGObject you could receive bug fixes and new functionality. Please feel free to reopen this bug if the problem still occurs with a newer version of PyGObject.