How to add a tooltip to a row of GTK.TreeView? (Python Bindings)

Hey, I posted this question a few days ago on Stackoverflow, but no one responded. Maybe you guys and girls here can help me out with my Problem … :slight_smile:

I’m trying to use the method “Gtk::TreeView::set_tooltip_row()” from PyGObject:

Here is what i am currently doing:

  treeView: gtk.TreeView = self.builder.get_object("base_tree_view")

  path: gtk.TreePath = gtk.TreePath.new_from_string("2")
  tooltip: gtk.Tooltip = gtk.Tooltip()
  tooltip.set_text("soos naaan")

  treeView.set_tooltip_row(tooltip, path)
  # treeView.set_tooltip_column(0)

I expected that this would show a tooltip on the third row of my GTK::TreeView (that i created using Glade), but it’s not working. There is no tooltip show when i hover with my mouse over this row.

treeView.set_tooltip_column(0) works fine (showing tooltips), so why isn’t treeView.set_tooltip_row() working?
I think the problem here could be, that you can’t create a Tooltip using the default constructor, but where else should it get the Tooltip from?

Best wishes

I found out, that when i define a tooltip handler for the whole TreeView widget (-> listen to the query_tooltip signal), i get a tooltip object as my fifth parameter.

If i use this tooltip object inside the handler in combination with the set_tooltip_row() method, it kind of works and shows the tooltip just for a single row.

    def show_tooltip(self, widget, x, y, keyboard_mode, tooltip: gtk.Tooltip):

        treeView: gtk.TreeView = self.main_window.builder.get_object(

        path: gtk.TreePath = gtk.TreePath.new_from_string("8:0")
        tooltip.set_text("soos naaan")
        treeView.set_tooltip_row(tooltip, path)

        return True

The problem is, that I can’t use one tooltip for all my rows. I would like to create multiple tooltip objects with different content and “register” them all at once using the treeView.set_tooltip_row() method.
And it would be nice if I could do this outside the handler.
How am I able to do that? Do I still have to use the listen to the query_tooltip event from the parent TreeView widget?

Any help appreciated!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.