import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk # noqa class App(Gtk.Window): def __init__(self): super().__init__() self.tip = self.tip_win = self.tip_lbl = None self.all = False self.set_size_request(250, 200) self.set_tooltip_text('Hi') self.connect("destroy", Gtk.main_quit) self.connect("query-tooltip", self._tip_cb) fixed = Gtk.Fixed() self.add(fixed) button = Gtk.Button("Button") button.set_size_request(80, 35) fixed.put(button, 50, 50) button.connect("clicked", self._show_tip) self.show_all() def _tip_cb(self, top_win, x, y, xt, tip): if self.tip_win is None: top_win.set_property("has-tooltip", False) self.tip = tip self.tip_lbl = Gtk.Label("Top window tip") self.tip.set_custom(self.tip_lbl) self.tip_win = self.tip_lbl.get_toplevel() return False def _show_tip(self, _): if self.tip is None: return self.tip.set_custom(self.tip_lbl) if self.all: self.tip_win.show_all() else: self.tip_win.show() self.all = not self.all if __name__ == "__main__": pyapp = App() Gtk.main()