← Back to team overview

gtg-user team mailing list archive

Strange behaviour of GdkEvent



I've noticed links no longer work in latest GTG's master. After looking at the issue, I've found it to be caused by Gdk.EventButton.button at the event handler not returning an int [1] but a Gdk.EventButton instead.

If I add the following lines to TaskView._tag_event (at GTG/gtk/editor/taskview.py):

   print("ev = {0} (type = {1})".format(ev, type(ev)))
   print("ev.button = {0} (type = {1})".format(ev.button, type(ev.button)))
   print("ev.any = {0} (type = {1})".format(ev.any, type(ev.any)))
   print("ev.type = {0} (type = {1})".format(ev.type, type(ev.type)))
   print("ev.time = {0} (type = {1})".format(ev.time, type(ev.time)))

I get the following output when I click on a link:

   ev = <GdkEvent at 0x1bd6dc0> (type = <class 'gi.overrides.Gdk.Event'>)
ev.button = <void at 0x1bd6dc0> (type = <class 'gi.overrides.Gdk.EventButton'>) ev.any = <void at 0x1bd6dc0> (type = <class 'gi.overrides.Gdk.EventAny'>) ev.type = <enum GDK_BUTTON_PRESS of type GdkEventType> (type = <class 'gi.repository.Gdk.GdkEventType'>)
   ev.time = 86408185 (type = <class 'int'>)

It looks as if for some attributes it's returning a subclass of the ev object instead of the actual attribute value as documented. If I change ev.button with ev.button.button, the expected int is returned.

Could someone explain what is happening? I can't find any reference to this behaviour in any place.

[1] https://lazka.github.io/pgi-docs/api/Gdk_3.0/structs/EventButton.html