code: def refresh_gui(delay=0.0001, wait=0.0001):
      
      time.sleep(delay)
      while gtk.events_pending():
          gtk.main_iteration_do(block=False)
          time.sleep(wait)
docs: Use up all the events waiting to be run
  
      :param delay: Time to wait before using events
      :param wait: Time to wait between iterations of events
  
      This function will block until all pending events are emitted. This is
      useful in testing to ensure signals and other asynchronous functionality
      is required to take place.