[GTK4] Widgets never destroyed
Since GTK4, gtk_widget_destroy() is not available anymore.
From the documentation, gtk_container_remove() should replace it.
But, with pygobject, calling Gtk.Container.remove() do not destroy widgets.
#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk, GLib, Pango
def on_destroy(widget):
print(widget)
window = Gtk.Window(title="Destroy my buttons")
box = Gtk.Box()
button = Gtk.Button(label="Hello")
button.connect("destroy", on_destroy)
window.set_child(box)
box.append(button)
GLib.timeout_add(4000, box.remove, button)
window.show()
loop = GLib.MainLoop()
loop.run()