When reading the documentation about GtkBuilder, I came across this passage:
A
Gtk.Builder
holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to callGtk.Widget.destroy()
to get rid of them and all the widgets they contain.
But this applies to python too? That is when I load a top-level window I must destroy it manually?
It is never necessary. But destruction of widgets has nothing to do with memory management, or at least not primarily. It is mainly a matter of existence in the GUI model. If you add a widget to a container, it remains there until destroyed. Even if you hide it, it is still there. It can respond to signals, is part of lists or whatever.