[SciPy-User] matlab "uigetfile" analog for ipython

David Baddeley david_baddeley at yahoo.com.au
Wed Aug 6 09:51:23 EDT 2014


It will depend on which GUI framework you are using. Hjalmar and Antonio have given answers for tk and Qt respectively. Under wx you'd use wx.FileDialog

e.g. (copy and pasted from a file I had open hence the slightly irrelevant message and wildcard):

import wx
fdialog = wx.FileDialog(None, 'Open 3D scene ...', wildcard='*.stl', style=wx.OPEN)
succ = fdialog.ShowModal()
        
if (succ == wx.ID_OK):
   fname = fdialog.GetPath().encode()

If you're using an iPython notebook in a browser (which it sounds like you might be), you're also going to need to tell iPython to start your gui backend of choice using a gui 'magic' - eg: %gui wx

cheers,
David


On Tuesday, 15 July 2014 6:22 AM, Antonino Ingargiola <tritemio at gmail.com> wrote:



Hi,

I use to define a function that uses Qt (either PySide or PyQt) to open a dialog:

try:
    from PySide import QtCore, QtGui
except ImportError:
    from PyQt4 import QtCore, QtGui

def gui_fname(dir=None):
    """Select a file via a dialog and returns the file name.
    """
    if dir is None: dir ='./'
    fname = QtGui.QFileDialog.getOpenFileName(None, "Select data file...", 
            dir, filter="All files (*)")
    return fname[0]


Antonino



On Sun, Jul 13, 2014 at 4:27 AM, Hjalmar Turesson <hturesson at gmail.com> wrote:

Hi,
>
>I used tkFileDialog for that type of thing.
>
>Hjalmar
>
>
>
>
>On Fri, Jul 11, 2014 at 9:39 AM, Antonelli Maria Rosaria <maria-rosaria.antonelli at curie.fr> wrote:
>
>Hi, 
>>
>>
>>Is there any way to select interactively the folder/directory where are stored the data that I want to analyse in my notebook.
>>Matlab command should be 'uigetfile'. This open a window and I select the file I want from this window.
>>
>>
>>Thank you very much.
>>Best,
>>Rosa
>>_______________________________________________
>>SciPy-User mailing list
>>SciPy-User at scipy.org
>>http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
>
>_______________________________________________
>SciPy-User mailing list
>SciPy-User at scipy.org
>http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


_______________________________________________
SciPy-User mailing list
SciPy-User at scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list