Enable PyGTK Eventbox motion-notify-event while is a Layout child

Posted by mkotechno on Stack Overflow See other posts from Stack Overflow or by mkotechno
Published on 2010-04-09T02:55:57Z Indexed on 2010/04/09 3:03 UTC
Read the original article Hit count: 326

Filed under:
|
|
|

I noticed when a Eventbox is added into a Layout some events are missed, this does not happend for example adding it to a Fixed (very similar widget), I tried to restore the event mask in this way with no sucess:

import pygtk
import gtk


def foo(widget, event):

    print event


pygtk.require('2.0')
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect('destroy', lambda x: gtk.main_quit())

eventbox = gtk.EventBox()
eventbox.connect('button-press-event', foo)   # works
eventbox.connect('motion-notify-event', foo)  # fail
eventbox.set_events(
    gtk.gdk.BUTTON_MOTION_MASK|               # restoring missed masks
    gtk.gdk.BUTTON1_MOTION_MASK|
    gtk.gdk.BUTTON2_MOTION_MASK|
    gtk.gdk.BUTTON3_MOTION_MASK)

layout = gtk.Layout()
image = gtk.image_new_from_file('/home/me/picture.jpg')

layout.add(image)
eventbox.add(layout)
window.add(eventbox)

window.show_all()
gtk.main()

How should I restore the missed event/mask?

© Stack Overflow or respective owner

Related posts about python

Related posts about gtk