def main(*argv): try: # Import Psyco if available import psyco psyco.full() except ImportError: print "psyco not available" mainwindow = gtk.Window() mainwindow.connect("delete_event", delete_event) mainwindow.set_default_size(WIDTH, HEIGHT) mainwindow.add(TheWorld) mainwindow.show() TheWorld.create_width = WIDTH TheWorld.create_height = HEIGHT TheWorld.show() TheEden.populate() #TheSpaceTime.start() #TheSpaceTime.timer_id = gobject.idle_add(TheSpaceTime.tick) #timer = gobject.timeout_add(1000, TheSpaceTime.start) # delay start of simulation thread TheSpaceTime.start() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave()
def delete_event(window, event): TheSpaceTime.stop() if TheSpaceTime.timer_id > 0: gobject.source_remove(TheSpaceTime.timer_id) window.hide() gtk.main_quit()