title: Python 3: urllib.request.urlopen and Progressbar
body: <p>I'm new to Python and have a problem with getting the content of some HTML files / urls and show the status with a progressbar:</p>
  
  <p>This is relevant Code I use:</p>
  
  <p>Progressbar:</p>
  
  <pre><code>def createProgressbar(self):
          self.progressbarVar = StringVar()
          self.progressbar = ttk.Progressbar( self.masterWindow, variable=self.progressbarVar, length=400, maximum=100, mode='determinate' )
          self.progressbar.place(x=100, y=760)
  
          self.progressbarStatus = Label( self.masterWindow, text='Please wait ...', bg='#fafafa', fg='#333', bd=0 )
          self.progressbarStatus.place(x=100, y=730)
  </code></pre>
  
  <p>Read HTML:</p>
  
  <pre><code>def readHTML(self):
          # Set new progressbar max, eg. 20 for 20 files to read
          self.progressbar.config(maximum=self.LinkListItemCount)
  
          # Progressbar Counter
          i=1
  
          # example for self.LinkListByCatDict
          # self.LinkListByCatDict = {'cat1': ['/test/asd.html', '/test/asd2.html'], 'cat2': ['/test/asd.html', '/test/asd2.html']}
  
          for item in self.LinkListByCatDict.items():
              actCategory = item[0]
  
              for linkItem in item[1]:
                  url = 'http://www.example.com'+linkItem
  
                  try:
                      req = urllib.request.Request( url )
                      open = urllib.request.urlopen( req )
                      requestContent = open.read()
  
  
                      if self.debug == True:
                          print('OK: '+url)
                  except:
                      if self.debug == True:
                          print('Error: '+url)
  
  
                  # Progressbar update
                  self.progressbarVar.set(i)
  
                  if self.debug == True:
                      print('Progressbar act: '+str(i))
  
                  i += 1
  </code></pre>
  
  <p>Generally that works fine, but while the loop is processed the whole interface shows only a beachball (Mac OS). At the end of the loop the progressbar jumps from 0 directly to 100%.</p>
  
  <p>Is there a better way to do that, without hanging up the interface?</p>