PyGTK Notebook button_press_event connection
Johan Dahlin
jdahlin at async.com.br
Tue Jan 24 08:58:58 EST 2006
> <code>
>
> notebook = gtk.Notebook()
> ...
> child = gtk.Frame()
> ...
> label = gtk.Label('Any text')
> label.connect('button_press_event', a_function)
> ...
> notebook.append_page(child, label)
>
> </code>
>
> But the button_press_event event is not intercepted (nothing happens
> when I click on the tab label).
A gtk.Label does not have a gdk window (as in the windowing system of gtk+),
so it cannot listen to events. A workaround is to put it in an eventbox:
eventbox = gtk.EventBox()
eventbox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
eventbox.connect('button-press-event', callback)
label = gtk.Label()
eventbox.add(label)
notebook.append_page(..., eventbox)
Perhaps you should subscribe to the PyGTK mailing list[1] though, where this
kind of question is more appropriately asked
[1]: http://www.daa.com.au/mailman/listinfo/pygtk
Johan Dahlin
More information about the Python-list
mailing list