import pygtk pygtk.require("2.0") import gtk import threading,time class MyThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy",self.win_destroy) self.button = gtk.Button("LALAL") self.button.show() self.window.add(self.button) self.window.show() def win_destroy(self,widget,data=None): gtk.main_quit() def run(self): gtk.main() if __name__ == '__main__': t = MyThread() t.start() for i in range(10): print "Bye" time.sleep(1) t.join()