Hii.
I have a drawing area with Cairo drawn content. On a certain event, I would like to pop a popover at a point within the area. This point varies depending on situation, thus not fixed.
This is what I tried (simple example with button and label)
import gi
gi.require_versions({"Adw": "1"})
from gi.repository import Adw, Gdk, Gtk
def on_activate(application):
win = Adw.ApplicationWindow(application=application)
pop = Gtk.Popover()
pop.set_child(Gtk.Label(label="Popover"))
box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL,
spacing=10,
margin_top=10,
margin_end=10,
margin_bottom=10,
margin_start=10,
)
label = Gtk.Label(label="Click the button to show popover.")
button = Gtk.Button(label="Show")
button.connect("clicked", lambda _: pop.popup())
pop.set_parent(box)
pop.set_pointing_to(Gdk.Rectangle(100, 100, 10, 10))
box.append(label)
box.append(button)
win.set_content(box)
win.set_default_size(200, 200)
win.present()
app = Adw.Application(application_id="com.example.app")
app.connect("activate", on_activate)
app.run([])
But this only produces the following result no matter the values provided to the rectangle.
I also get this warning.
DeprecationWarning: Passing arguments to gi.types.Boxed.__init__() is deprecated. All arguments passed will be ignored.
pop.set_pointing_to(Gdk.Rectangle(100, 100, 10, 10))
Any idea how I can accomplish this?