#!/usr/bin/python

import gtk, gobject, gc, sys

if (len (sys.argv) != 2):
  print 'usage: %s bigimage' % sys.argv[0]
  sys.exit(1)

def create_window():
    gc.collect()
    window = gtk.Window()
    window.add (MyBox())
    window.show_all()
    
class MyBox(gtk.HBox):
  def __init__(self):
    self.__gobject_init__()
    button = gtk.Button('eat more memory')
    self.pixbuf = gtk.gdk.pixbuf_new_from_file(sys.argv[1])
    button.connect('clicked', self.close)
    self.add(button)

  def close(self, button):
    window = self.get_parent()
    # we remove ourselves here explicitly as winow.destroy() disconnects all
    # signal handlers and with that breaks the cycle
    window.remove(self)
    window.destroy()
    del window
    create_window()


gobject.type_register(MyBox)
create_window()
gtk.main()
