Python garbage collection and gtk windows -
in following program have button spawns popup. simple enough. connect main window's delete-event
gtk.main_quit()
closing main window closes program.
without keep running until kill process (as evidenced occupied cli prompt) question is: happens popup window when click away?
is window automatically being destroyed @ delete-event
or hide , linger somewhere in memory until program ends?
#!/usr/bin/python3 gi.repository import gtk class mainwin(gtk.window): def __init__(self): gtk.window.__init__(self) button = popupbutton() self.add(button) self.show_all(); self.connect("delete-event", gtk.main_quit) class popupbutton(gtk.button): def __init__(self): gtk.button.__init__(self, label="popup") self.connect("clicked", self.clicked) def clicked(self, widget): win = popupwindow() win.set_transient_for(self.get_toplevel()) win.show() class popupwindow(gtk.window): def __init__(self): gtk.window.__init__(self) self.add(gtk.label(label="popups! popups everyone!")) self.show_all() win = mainwin() win.show() gtk.main()
the default response delete-event
signal destroy window. so, unless you're handling signal, popup window destroyed.
Comments
Post a Comment