title: Progress bar in pyqt not updating properly for reading file
body: <p>I have a progress bar in an app that is supposed to progress as the file gets read but it's not updating at all with my set condition. It seems I need to give the variable responsible for updating the progress bar an explicit value instead of another variable. Please look at the code below, specifically my <code>loadfile</code> function.</p>
  
  <pre><code>import sys
  from PyQt4 import QtCore, QtGui
  import subprocess
  from time import sleep
  
  class AppView(QtGui.QDialog):
  
      def __init__(self, parent=None):
          super(AppView, self).__init__(parent)
          self.resize(400, 400)
          self.buttonStart = QtGui.QPushButton(self)
          self.buttonStart.setText("Start")
          self.buttonStart.clicked.connect(self.start)
  
          self.progress = QtGui.QProgressBar(self)
          self.progress.setGeometry(200, 80, 250, 20)
          verticalLayout = QtGui.QVBoxLayout(self)
          verticalLayout.addWidget(self.buttonStart)
          verticalLayout.addWidget(self.progress)
  
      def line_count(self):
          p = subprocess.Popen(['wc', '-l', 'xfile'], stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
          result, err = p.communicate()
          if p.returncode != 0:
              raise IOError(err)
          return int(result.strip().split()[0]) #returns 407 lines
  
      def start(self):
          self.loadfile()
  
      def loadfile(self):
          x = 100/self.line_count()
          loading = 0
  
          file_in = "xfile"
          with open(file_in) as f:
              for line in f:
                  #sleep(0.1)
                  print line
                  loading += x
                  #loading += 0.245700246
                  self.progress.setValue(loading)
  
  if __name__ == '__main__':
      app = QtGui.QApplication(sys.argv)
      appview = AppView()
      appview.show()
      sys.exit(app.exec_()) 
  </code></pre>
  
  <p>However, if I set loading like this <code>loading += 0.245700246</code> it works. I don't understand why <code>loading += x</code> doesn't do the same thing as it also returns 0.245700246.</p>
  
  <p>Another issue is that when it works and the progress bar is updating, the entire UI is frozen. It's like it's using all the ui threads and I don't know how to get around that yet. I cannot close the app or do anything else.</p>