[Tutor] open-file GUI

FT chester_lab at fltg.net
Fri Jul 4 20:11:27 CEST 2008

    My demo is from wspython. The Hebrew window messed up my reading and now
I have included the imports and the initial assignment. You can place them
in caps for global vars, but place them inside a class so they are

I am starting to use Python+NumPy+SciPy+Matplotlib as a substitute to

I need a simple GUI that can help me to open files and save file i.e.
something similar to uigetfile in MATLAB.
Is there a simple script that opens a window with a possibility to browse
through the file system and pick an ASCII file ?
After the file is spcified using the GUI, I want to read it using fromfile
and similar commands.
After I process the data I want a similar GUI that enables choosing the path
and name for saving the results file.

Are scripts of this type available ?

Eli Brosh

This method allows you to either display the last file name or change the fn
to "" for an open command so it does not display the file name. Then fn
assignment commented out...

import wx
import os

dirname=os.getcwd()  #SEARCH FROM PRESENT DIRECTORY!

    def setFilePath(self, type4file=""):
        " Search directory for path and file name!"
        t4f = wx.OPEN
        if type4file[0] in "sS":
            t4f = wx.SAVE|wx.FD_OVERWRITE_PROMPT
#            fn = self.filename
        dlg = wx.FileDialog(self, self.filename +" or Choose a file",
self.dirname, fn, "*.*", t4f)
        if dlg.ShowModal() == wx.ID_OK:
            self.filename = dlg.GetFilename()
            self.dirname = dlg.GetDirectory()

More information about the Tutor mailing list