<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

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to