当我读到关于GtkBuilder的documentation时,我看到了这段话:
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.
但这也适用于python吗?也就是说,当我加载一个顶级窗口时,我必须手动销毁它?在
从来没有必要。但小部件的销毁与内存管理无关,或者至少主要与内存管理无关。这主要是GUI模型中存在的问题。如果你把一个小部件添加到一个容器中,它会一直保持在那里直到被销毁。即使你把它藏起来,它依然存在。它可以对信号做出反应,是列表的一部分或其他什么。在
嗯,差不多吧。通常不必手动调用窗口上的
destroy()
,因为当用户单击窗口的关闭按钮时,它会自动发生。在相关问题 更多 >
编程相关推荐