import gc
import gtk

class SomeWindow(object):

    def __init__(self):
        self.button = gtk.Button("Click me")
        self.button.connect("clicked", self._on_button_clicked)
        
        self.window = gtk.Window()
        self.window.add(self.button)
        
        print self.__dict__  # this prints a populated dict
    
    def show(self):
        self.window.show_all()
    
    def _on_button_clicked(self, *_):
        print self.__dict__  # this prints {}

if __name__ == "__main__":
    print "Before window creation:", gc.collect()
    SomeWindow().show()
    print "After window creation:", gc.collect()
    gtk.main()

