How to declare a signal handler getting passed a GdkEventButton as argument

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to declare a signal handler getting passed a GdkEventButton as argument

Christian Mallwitz
Hi,

I want to declare a signal handler as in

__gsignals__ = {
        'foo':        (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_POINTER,)),
    }

I have a do_foo method but the parameter passed is actually a
GdkEventButton (or rather a Gdk.EventButton in Python) - the signal is
emitted in a 'button-press-event' signal handler.

My problem is the event object I have in the 'button-press-event'
signal handler and pass when emitting 'foo' is not a
GObject.TYPE_POINTER. I tried GObject.TYPE_OBJECT as well to no avail.

The error is: TypeError: could not convert type EventButton to
gpointer required for parameter 0

How do I declare a signal handler such that I can pass a
GdkEventButton instance as argument to the signal handler?

Thanks
Christian
_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: How to declare a signal handler getting passed a GdkEventButton as argument

Timo List
Op 21-04-13 18:55, Christian Mallwitz schreef:

> Hi,
>
> I want to declare a signal handler as in
>
> __gsignals__ = {
>          'foo':        (GObject.SignalFlags.RUN_LAST, None,
> (GObject.TYPE_POINTER,)),
>      }
>
> I have a do_foo method but the parameter passed is actually a
> GdkEventButton (or rather a Gdk.EventButton in Python) - the signal is
> emitted in a 'button-press-event' signal handler.
>
> My problem is the event object I have in the 'button-press-event'
> signal handler and pass when emitting 'foo' is not a
> GObject.TYPE_POINTER. I tried GObject.TYPE_OBJECT as well to no avail.
>
> The error is: TypeError: could not convert type EventButton to
> gpointer required for parameter 0
>
> How do I declare a signal handler such that I can pass a
> GdkEventButton instance as argument to the signal handler?
I had to do the same when porting an application from GTK2 to GTK3.

GTK2 version:
     __gsignals__ = {
         'clicked' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING, gtk.gdk.Event))
     }

GTK3 version:
     __gsignals__ = {
         'clicked' : (GObject.SIGNAL_RUN_LAST, None, (str, object))
     }

I was confused at the beginning because Gdk.Event didn't work anymore,
but passing it as a Python object seems to do the trick.

Timo

>
> Thanks
> Christian
> _______________________________________________
> pygtk mailing list   [hidden email]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: How to declare a signal handler getting passed a GdkEventButton as argument

Christian Mallwitz
'object' as type worked
Thanks!
Christian

On Sun, Apr 21, 2013 at 7:25 PM, Timo <[hidden email]> wrote:

> Op 21-04-13 18:55, Christian Mallwitz schreef:
>>
>> Hi,
>>
>> I want to declare a signal handler as in
>>
>> __gsignals__ = {
>>          'foo':        (GObject.SignalFlags.RUN_LAST, None,
>> (GObject.TYPE_POINTER,)),
>>      }
>>
>> I have a do_foo method but the parameter passed is actually a
>> GdkEventButton (or rather a Gdk.EventButton in Python) - the signal is
>> emitted in a 'button-press-event' signal handler.
>>
>> My problem is the event object I have in the 'button-press-event'
>> signal handler and pass when emitting 'foo' is not a
>> GObject.TYPE_POINTER. I tried GObject.TYPE_OBJECT as well to no avail.
>>
>> The error is: TypeError: could not convert type EventButton to
>> gpointer required for parameter 0
>>
>> How do I declare a signal handler such that I can pass a
>> GdkEventButton instance as argument to the signal handler?
>
> I had to do the same when porting an application from GTK2 to GTK3.
>
> GTK2 version:
>     __gsignals__ = {
>         'clicked' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
> (gobject.TYPE_STRING, gtk.gdk.Event))
>     }
>
> GTK3 version:
>     __gsignals__ = {
>         'clicked' : (GObject.SIGNAL_RUN_LAST, None, (str, object))
>     }
>
> I was confused at the beginning because Gdk.Event didn't work anymore, but
> passing it as a Python object seems to do the trick.
>
> Timo
>
>>
>> Thanks
>> Christian
>> _______________________________________________
>> pygtk mailing list   [hidden email]
>> http://www.daa.com.au/mailman/listinfo/pygtk
>> Read the PyGTK FAQ: http://faq.pygtk.org/
>
>
> _______________________________________________
> pygtk mailing list   [hidden email]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/