It's pretty simple, but you need a few hacks.
First you need to get Gtk to create a header button for the GtkTreeViewColumn:
label = gtk.Label("Column title") label.show() treeview_column.set_widget(label)
After that, you need to get the internal GtkButton header:
widget = treeview_column.get_widget() while not isinstance(widget, gtk.Button): widget = widget.get_parent()
Finally, with a link to a button, you can do something useful:
def button_release_event(button, event): if event.button == 3: menu.popup(event) widget.connect('button-release-event', button_release_event)
This was taken from the kiwi library, which has an ObjectList that provides a python list such as api for creating GtkTreeViews.
source share