[pygtk] registering signal callback function

Lauro Moura lauromoura at gmail.com
Wed Jul 4 17:52:35 WST 2007


On 7/2/07, varun_shrivastava <shrivastavavarun at yahoo.co.in> wrote:
>
> hi Felix
>
>   i mean to say, i have a class which registers certain signals using
> g_signal_new
> 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
> code.
>
> ie to say
> from python i will call a function as
>
> defs p:
> ...
> ...
>
> demo.register_callback(p)
>
> this will call wrapper function register_callback which looks like
>
> static PyObject *
> _wrap_register_callback(........)
> {
>         .......
>         PyArg_ParseTuple(); //----> conversion from python to C
>
>        g_signal_connect(..,..,GCALLBACK(dummy),....)
>
>      .....
> }
>
>
> and in dummy function i will write the code to call python function "p"
>
> will this be OK or is there any other method
>
>

Maybe you can send the pointer to the python callback as user_data,
wich will be recieved by the C callback, without need of that dummy
variable.

-- 
Lauro Moura ("lmoura" on Freenode)
http://lauro.wordpress.com


More information about the pygtk mailing list