title: How do I keep GUI from freezing, while calling a function? (PyQT4, Python3)
body: <h2>Question Background:</h2>
  
  <p>I'm new to PyQT4. I am developing a program with it and I am web scraping to get data into my program. While the information is downloading my GUI locks up. I would like to call this function in a separate background thread, perhaps using QThread, but I am having a tough time wrapping my head around QThread, Qt in general, and the slot/signal way of communication.</p>
  
  <p>I have read about making a generic worker thread that will call any  function passed to it. I don't know how to implement it in my main file so that I can run my functions as a background process. If any example code could be shown, please explain each line in detail as I am not understanding the process.</p>
  
  <h2>Questions:</h2>
  
  <ol>
  <li>How can I prevent my GUI from freezing while a function is running?</li>
  <li>How could I use a background thread to run functions from my class?</li>
  </ol>
  
  <h2>Code:</h2>
  
  <p>My ui is loaded in from an external file created by Qt 4 Designer.</p>
  
  <p><a href="https://github.com/mkelley88/BiddergyBrowser" rel="nofollow">Full files on Github</a></p>
  
  <pre><code>class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(_fromUtf8("MainWindow"))
  </code></pre>
  
  <p>main.py (Main file)</p>
  
  <pre><code>def connections():
      # If button is clicked, call summary(), which web scrapes 
      # for data. This could take 5-30 seconds, this freezes UI.
      ui.btnRefreshSummary.clicked.connect(lambda: summary())
  
  # Refresh items in gui
  def refresh_ui():
      if summary_data != []:
          ui.valWatching.setText(summary_data[0])
          ui.valBidding.setText(summary_data[1])
          ui.valWon.setText(summary_data[2])
          ui.valNotWon.setText(summary_data[3])
          ui.valPurchases.setText(summary_data[4])
          ui.valInvoices.setText(summary_data[5])
  
  def login():
      # Scrape website and login while in background; 
      # This locks up GUI until it completes.
      # Pretend this sleep command is the time it takes to login
      time.sleep(5)  # &lt;-This would lock it up for 5 seconds
  
  if __name__ == "__main__":
      app = QtGui.QApplication(sys.argv)
      MainWindow = QtGui.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      connections()
      # Load credentials from file.
      with open('login.txt') as f:
          credentials = f.readline().strip().split(':')
      f.closed
  
      # Login, download summary, then refresh the UI.
      b = Biddergy()
      b.login(credentials[0],credentials[1])
      summary_data = b.summary()
      b.logout()
  
      refresh_ui()
      sys.exit(app.exec_())
  </code></pre>