peng3d/gui/__init__.py
def delWidget(self,widget):
        """
        Deletes the widget by the given name.
        
        Note that this feature is currently experimental as there seems to be a memory leak with this method.
        """
        # TODO: fix memory leak upon widget deletion
        #print("*"*50)
        #print("Start delWidget")
        if isinstance(widget,BasicWidget):
            widget = widget.name
        
        if widget not in self.widgets:
            return
        
        w = self.widgets[widget]
        
        #print("refs: %s"%sys.getrefcount(w))
        
        w.delete()
        del self.widgets[widget]
        del widget
        
        #w_wref = weakref.ref(w)
        
        #print("GC: GARBAGE")
        #print(gc.garbage)
        #print("Widget Info")
        #print(w_wref())
        #import objgraph
        #print("Objgraph")
        #objgraph.show_refs([w], filename='./mem_widget.png')
        #print("refs: %s"%sys.getrefcount(w))
        #w_r = gc.get_referrers(w)
        #print("GC: REFS")
        #for w_ref in w_r:
        #    print(repr(w_ref)[:512])
        #print("GC: END")
        #print("len: %s"%len(w_r))
        #del w_ref,w_r
        #print("after del %s"%w_wref())
        #print("refs: %s"%sys.getrefcount(w))
        del w
def delWidget(self,widget):
        """
        Deletes the widget by the given name.
        
        Note that this feature is currently experimental as there seems to be a memory leak with this method.
        """
        # TODO: fix memory leak upon widget deletion
        #print("*"*50)
        #print("Start delWidget")
        if isinstance(widget,BasicWidget):
            widget = widget.name
        
        if widget not in self.widgets:
            return
        
        w = self.widgets[widget]
        
        #print("refs: %s"%sys.getrefcount(w))
        
        w.delete()
        del self.widgets[widget]
        del widget
        
        #w_wref = weakref.ref(w)
        
        #print("GC: GARBAGE")
        #print(gc.garbage)
        #print("Widget Info")
        #print(w_wref())
        #import objgraph
        #print("Objgraph")
        #objgraph.show_refs([w], filename='./mem_widget.png')
        #print("refs: %s"%sys.getrefcount(w))
        #w_r = gc.get_referrers(w)
        #print("GC: REFS")
        #for w_ref in w_r:
        #    print(repr(w_ref)[:512])
        #print("GC: END")
        #print("len: %s"%len(w_r))
        #del w_ref,w_r
        #print("after del %s"%w_wref())
        #print("refs: %s"%sys.getrefcount(w))
        del w
Deletes the widget by the given name.
        
        Note that this feature is currently experimental as there seems to be a memory leak with this method.