[pygtk] unable to wrap my Interface

Lauro Moura lauromoura at gmail.com
Thu Aug 16 20:14:47 WST 2007


On 8/16/07, varun_shrivastava <shrivastavavarun at yahoo.co.in> wrote:
>
> hi
> i have a query regarding constructors.
> Is it mandatory to have  *_new () function for a widget. Or Can i declare a
> function like *_new_<something>(). {from the code generation point of view.
> using pygtk-codegen-2.0}
> I want to know about it because if we look at the *_wrap.c file generated,
> we see that if the function declaration is *_new() than the wrappercode
> returns an "int"
>

About returning int, two functions are involved when you create a new
instance: an allocation function (__new__) and an initialization
(__init__) function. The _new() wrapper maps to the initialization
function, which should return an int.

For the _new_<something>(), they aren't treated as constructors of the
python type, but as simple module functions. They get a GObject
instance from the c function and the pygobject_new function will
handle that registration.

For more info, see [1].

[1] - http://www.python.org/doc/ext/node22.html
-- 
Lauro Moura ("lmoura" on Freenode)
http://lauro.wordpress.com


More information about the pygtk mailing list