title: Python GUI: How to browse a directory and read ALL files in it?
body: <p>This'd be my first post here, and I'm having serious issues about file reading with Python GUI. </p>
  
  <p>So, I'm totally lost in trying to figure a smarter way to write a code in Python 2.7 using GUI to browse a directory and read ALL files in it for further operations. In my case, the files I'm reading are images and I'm trying to save it in an array.</p>
  
  <p>I'm using those numpy, scikits etc, for easing my image-processing work. I am trying to process 3 images named "pulse1.jpg" to "pulse3.jpg".</p>
  
  <p>Here's my work below. My apologies if it's kinda bit messy/unclear, especially since I can't post images yet:</p>
  
  <pre><code>import os
  import numpy as np
  import cv2
  from matplotlib import pyplot as plt
  from skimage import color, data, restoration
  
  # first we specify the file directory
  directory = 'I:\\My Pictures\\toby arm pics'
  filename = "pulse"
  
  # initiate file reading
  isfile = os.path.isfile
  join = os.path.join
  
  # first, we get the number of files (images)
  # in the directory 
  number_of_files = sum(1 for item in os.listdir(directory)\
                    if isfile(join(directory, item)))
  
  X = [] # we'll store the read images here
  i = 1  # initiate iteration for file reading
  string = "" # initiation
  
  # read the images from directory 
  # and save it to array X
  while i &lt;= number_of_files:
     string = directory + "\\" + filename + str(i) + ".jpg"
     temp = cv2.imread(string, -1)
     X.append(temp)
  i += 1
  </code></pre>
  
  <p>Thank you so much for your help, guys!</p>