[pygtk] registering signal callback function

varun_shrivastava shrivastavavarun at yahoo.co.in
Tue Jul 3 19:49:54 WST 2007

hi Felix

  i mean to say, i have a class which registers certain signals using
and i have to use g_signal_connect to register a callback function.

Now i am generating python bindings for this class, but  i m not sure about
how to register callback functions that will be written in python.

should i provide a wrapper function which will take python object as
argument and will
internally register a dummy signal callback function using g_signal_connect. 
this dummy function will than provide a mechanism to call python code from C

ie to say
from python i will call a function as

defs p:


this will call wrapper function register_callback which looks like

static PyObject *
        PyArg_ParseTuple(); //----> conversion from python to C



and in dummy function i will write the code to call python function "p"

will this be OK or is there any other method


varun_shrivastava wrote:
> hi Felix
>    i want to ask, how can i access g_signal_connect_* family of APIs from
> python
> do i need to write a c code that will act as a callback for signal
> handler, and
> in that c code i will call python functions
> bye
> varun
> Felix Rabe (public) wrote:
>> Hash: SHA1
>> Hi Varun,
>> varun_shrivastava wrote:
>>> hi
>>> i m new to pygtk
>>> and want to know how its better to use
>>> pygtk rather than gtk
>>> what r its pros and cons
>> GTK+:
>> 	Use GTK+ if your programming language is C
>> - -	It is more cumbersome to program
>> +	Your application executes faster
>> PyGTK:
>> 	Use PyGTK if your programming language is Python
>> +	It is easier (and more fun :) ) to program
>> - -	Your application executes more slowly
>> Start out with the programming language you know.  Lern GTK+ if you know
>> C, or PyGTK if you know Python.  If you don't know either C or Python,
>> Python is *way* easier to learn than C, but C is also simple enough.  I
>> learned both (C / GTK+ first).
>> I personally browse the GTK+ source code (yes, the library's code)
>> sometimes to find out "best practise" / some examples / how stuff works.
>>  But normally you do not need to do this if you just program in PyGTK
>> and are not a perfectionist like me. :o)
>> Greetings,
>> Felix
>> Version: GnuPG v1.4.6 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>> iD8DBQFGcrzLlW86h1QHmOcRAsdVAKDKl+jf1eh2Iw+pZIqyAaHFSArH/QCgm1zP
>> fAE8rQzsR3sUNovMVrfsTuo=
>> =hdzm
>> -----END PGP SIGNATURE-----
>> _______________________________________________
>> 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/Pygtk-or-gtk-tf3913322.html#a11394462
Sent from the Gtk+ - Python mailing list archive at Nabble.com.

More information about the pygtk mailing list