[pygtk] unable to wrap my Interface
varun_shrivastava
shrivastavavarun at yahoo.co.in
Thu Aug 16 14:30:18 WST 2007
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"
static int
_wrap_*_new(PyGObject *self, PyObject *args, PyObject *kwargs)
{
.......
......
pygobject_register_wrapper((PyObject *)self);
return 0;
}
whereas if the function declaration is like *_new_<something> () than
generated code looks like
static PyObject *
_wrap_*_new_with_<something>(PyGObject *self, PyObject *args, PyObject
*kwargs)
{
....
...
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
}
So what i can see is the *_new() is doing some kind of registration which is
not done in *_new_<something>(), so is it so that a widget cannot declare
*_new_<something> untill it has a declaration like *_new(). Obviously if i
declare one of them the code will be generated, will get compiled and will
run but that some kind of registration in *_new() is not being done.
This question again comes to mind when: what if a user calls
*_new_<something> before *_new()? [he can call anything depending upon his
choice]
So, is that registration important. (i think so)
I looked through the gtk.override file found something like "use of optional
arguments in PyArg_ParseTuple"
override gtk_list_item_new kwargs
static int
_wrap_gtk_list_item_new(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "label", NULL };
gchar *text = NULL;
if (PyErr_Warn(PyExc_DeprecationWarning, "use gtk.TreeView") < 0)
return -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"|z:GtkListItem.__init__",
kwlist, &text))
return -1;
if (text)
self->obj = (GObject *)gtk_list_item_new_with_label(text);
else
self->obj = (GObject *)gtk_list_item_new();
if (!self->obj) {
PyErr_SetString(PyExc_RuntimeError, "could not create GtkListItem
object");
return -1;
}
pygobject_register_wrapper((PyObject *)self);
return 0;
}
so if i declare only *_new_<something> than do i need to override it myself
so that it does the job of registering the wrapper?
varun:working:
Gian Mario Tagliaretti-3 wrote:
>
> 2007/8/14, John Finlay <finlay at moeraki.com>:
>
>> h2def.py doesn't write define-interface lines if I recall correctly -
>> just change the define-object line. You could try defsgen.py:
>>
>> http://svn.gnome.org/viewcvs/pygtk/trunk/codegen/defsgen.py?view=log
>>
>> which uses ctypes to generate .defs - its more comprehensive in
>> generating .defs.
>
> else you can change manually object to interface and use scanvirtuals.py
>
> http://svn.gnome.org/viewcvs/pygtk/trunk/codegen/scanvirtuals.py?view=log
>
> to retrive the virtual methods.
>
> cheers
> --
> Gian Mario Tagliaretti
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
>
--
View this message in context: http://www.nabble.com/unable-to-wrap-my-Interface-tf4266619.html#a12176017
Sent from the Gtk+ - Python mailing list archive at Nabble.com.
More information about the pygtk
mailing list