title: PyGTK with threading, gobject, send signal from another thread?
body: <p>I'm new to Python, I want open a web page(here is google.com) using pywebkitgtk<br>
  then countdown with another thread,<br>
  when time's up, send a signal to webview, download the html as file </p>
  
  <p>Is there a way to open a web-page in gtk.main and countdown in background thread, then send a signal to GUI, make GUI do something..</p>
  
  <p>reference material:  </p>
  
  <ol>
  <li><a href="https://github.com/smolleyes/gmediafinder2/blob/master/data/scripts/get_stream.py" rel="nofollow">Downloading a page’s content with python and WebKit</a>  </li>
  <li><a href="http://faq.pygtk.org/index.py?req=show&amp;file=faq20.006.htp" rel="nofollow">using a separate thread to run code, two approaches for threads in PyGTK.</a></li>
  </ol>
  
  <p>here is my code, it cannot run, I guess I do not understand Python's <code>Class</code>...  </p>
  
  <pre><code>#!/usr/bin/env python
  import sys, threading
  import gtk, webkit
  import time
  import gobject
  
  gobject.threads_init()
  google = "http://www.google.com"
  
  class WebView(webkit.WebView):
      #return page's content
      def get_html(self):
          self.execute_script('oldtitle=document.title;document.title=document.documentElement.innerHTML;')
      html = self.get_main_frame().get_title()
      self.execute_script('document.title=oldtitle;')
      return html
  
  #wait 5 senconds and send a signal
  class TimeSender(gobject.GObject, threading.Thread):
      def __init__(self):
          self.__gobject_init__()
          threading.Thread.__init__(self)
  
      def run(self):
          print "sleep 5 seconds"
          time.sleep(5)
          self.emit("Sender_signal")
  
  gobject.type_register(TimeSender)
  gobject.signal_new("Sender_signal", TimeSender, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
  
  #PywebkitGTK, open google.com, receive signal
  class Window(gtk.Window, gobject.GObject):
      def __init__(self, time_sender, url):
          self.__gobject_init__()
          gtk.Window.__init__(self)
          time_sender.connect('Sender_signal', self._finished_loading)
          self._url = url
  
      def open_page(self):
          view = WebView()
          view.get_html()
          view.open(self._url)
          self.add(view)
          gtk.main()
      #write html to file
      def _finished_loading(self, view):
          with open("pagehtml.html", 'w') as f:
              f.write(view.get_html())
          gtk.main_quit()
  
  '''
  def user_callback(object):
      with open("pagehtml2.html", 'w') as f:
          f.write(view.get_html())
      gtk.main_quit()
  '''
  
  if __name__ == '__main__':
      time_sender = TimeSender()
      window = Window(time_sender, google)
      #time_sender.connect("Sender_signal", user_callback)
      time_sender.start()
      window.open_page()
  </code></pre>
  
  <p>I got an error:<br>
  <code>AttributeError: 'TimeSender' object has no attribute 'get_html'</code><br>
  I've been confused for a few days... thanks  </p>