title: Gtk.ProgressBar not working in Python
body: <p>I'm trying to use a progress bar in <strong>Python</strong> and <strong>Gtk3</strong>, but it doesn't get updated. I have read <a href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/progressbar.html" rel="nofollow">this</a> documentation and some questions in this forum (mostly for pygtk) and I really don't get it!</p>
  
  <p>I made a code for testing purposes only. When you click a button, it reads the contents of a directory recursively. My intention is to use a progress bar while reading all these files.</p>
  
  <p>This is the whole code:</p>
  
  <pre><code>import os
  from gi.repository import Gtk
  
  class MyWindow(Gtk.Window):
      """Progress Bar"""
  
      def __init__(self):
          Gtk.Window.__init__(self, title='Progress Bar')
          self.set_default_size(300, 75)
          self.set_position(Gtk.WindowPosition.CENTER)
          self.set_border_width(10)
  
          # read dir contents
          mydir = 'Documents'
          home_path = os.environ.get('HOME')
          dir_path = os.path.join(home_path, mydir)
          self.dir_files_list(dir_path)
  
          # create a grid
          self.grid = Gtk.Grid(column_homogeneous=True, row_homogeneous=True,
                               column_spacing=10, row_spacing=10)
          self.add(self.grid)
  
          # create a progress bar
          self.progressbar = Gtk.ProgressBar()
          self.grid.add(self.progressbar)
  
          # create a button
          self.button = Gtk.Button(stock=Gtk.STOCK_APPLY)
          self.button.connect('clicked', self.on_button_pressed)
          self.grid.attach(self.button, 0, 1, 1, 1)
  
      # function to read the dir contents
      def dir_files_list(self, dir_path):
          self.dir_list = []
          for root, dirs, files in os.walk(dir_path):
              for fn in files:
                  f = os.path.join(root, fn)
                  self.dir_list.append(f)
  
      # function to update the progressbar
      def on_button_pressed(self, widget):
          self.progressbar.set_fraction(0.0)
          frac = 1.0 / len(self.dir_list)
          for f in self.dir_list:
              new_val = self.progressbar.get_fraction() + frac
              print new_val, f
              self.progressbar.set_fraction(new_val)
          return True
  
  def main():
      """Show the window"""
      win = MyWindow()
      win.connect('delete-event', Gtk.main_quit)
      win.show_all()
      Gtk.main()
      return 0
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>Any help from a more experienced programmer is appreciated!</p>