title: IPython Notebook: Open/select file with GUI (Qt Dialog)
body: <p>When you perform the same analysis in a notebook on different data files, may be handy to graphically select a data file.</p>
  
  <p>In my python scripts I usually implement a QT dialog that returns the file-name of the selected file:</p>
  
  <pre><code>from PySide import QtCore, QtGui
  
  def gui_fname(dir=None):
      """Select a file via a dialog and return the file name.
      """
      if dir is None: dir ='./'
      fname = QtGui.QFileDialog.getOpenFileName(None, "Select data file...", 
              dir, filter="All files (*);; SM Files (*.sm)")
      return fname[0]
  </code></pre>
  
  <p>However, running this function from an notebook </p>
  
  <pre><code>full_fname = gui_fname()
  </code></pre>
  
  <p>causes the kernel to die (and restart):</p>
  
  <p>Interestingly, puttying this 3 command in 3 separate cells works</p>
  
  <pre><code>%matplotlib qt
  full_fname = gui_fname()
  %matplotlib inline
  </code></pre>
  
  <p>but when I put those commands in one single cell the kernel dies again.</p>
  
  <p>This prevents  to create a function like <code>gui_fname_ipynb()</code> that transparently allows selecting a file with a GUI.</p>
  
  <p>For convenience, I created a notebook illustrating the problem:</p>
  
  <ul>
  <li><a href="http://nbviewer.ipython.org/gist/anonymous/8138346">Open/select file with GUI (Qt Dialog)</a></li>
  </ul>
  
  <p>Any suggestion on how to execute a dialog for file selection from within an IPython Notebook?</p>