Search code examples
pythongtkgtk3osmgpsmapgtkoverlay

How do I make a GTKOverlay not take ALL interaction away from widgets under?


I have a map I have to attribute and I see the GtkOverlay seems to be the right widget. Unfortunately I can add a label, for example, it shows over the map widget... but even if the label is not so tall, not set to pack fill, it still removes all interaction from the map below.

    overlay = Gtk.Overlay()
    overlay.add(self.osm)
    top_container = Gtk.VBox()
    btmlbl = Gtk.Label("(c) so and so");
    top_container.pack_end(btmlbl, False, False, 0)
    self.vbox.pack_start(overlay, True, True, 0)
    overlay.add(btmlbl)
    overlay.add_overlay(top_container)

How do I make the overlay just overlay one label, image to take the click interaction only when cursor is on that element??


Solution

  • The answer's in the documentation...

        overlay.set_overlay_pass_through(container,True)
        overlay.set_overlay_pass_through(labelcontrol,False)
    

    Actually, the labelcontrol doesn't need that as long as it has an adjusment to make it clickable:

        lbl.set_has_window(True)
        lbl.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
        lbl.connect("button-press-event",function)