import threading
import time
import gtk


class ExampleThread(threading.Thread):
	
  stopthread = threading.Event()

  def run(self):
    print "Started"
    while not self.stopthread.isSet() :
      print "In thread"
      time.sleep(0.1)
  		
  def stop(self):
    self.stopthread.set()


def main_quit(obj):
  global et
  et.stop()
  gtk.main_quit()


window = gtk.Window()
progressbar = gtk.ProgressBar()
window.add(progressbar)
window.show_all()
window.connect('destroy', main_quit)


gtk.gdk.threads_init()

et = ExampleThread()
et.start()

gtk.main()
