>I'm trying to produce a menu effect in PyGTK similar to the Mozilla tab bar, >where a right-click on the tab produces a popup menu to perform various >actions on the tabs (and/or contents thereof). I can get most of the way >(sort of) with a button-press-event handler, but there's a couple of things >I can't manage to effect: (a) A right-click on the untabbed portion of the >tab list still gives the menu, and (b) I can't work out which tab was >clicked on.
For (a), you can call notebook.popup_disable() when you create the notebook, as long as you don't need the default popup menu that the notebook creates. For an easy way to create popup menus, and figuring out which tab a click comes from, put your tab labels into event boxes: tab_label_box = gtk.EventBox() tab_label = gtk.Label("Some label here") tab_label_box.add(tab_label) tab_label_box.connect('event', on_tab_click) notebook.append_page(your_page_widget, tab_label_box) def on_tab_click(self, widget, event, child): if event.type == gtk.gdk.BUTTON_PRESS: n = notebook.page_num(child) # this will automagically switch to whatever page you click on notebook.set_current_page(n) if event.button == 3: menu = create_a_menu() # I still use the ItemFactory menu.popup(None, None, None, event.button, event.time) _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/