Author: bugman Date: Tue Jan 26 13:45:24 2010 New Revision: 10374 URL: http://svn.gna.org/viewcvs/relax?rev=10374&view=rev Log: Modified the operation of openfile(). The directory is now set to getcwd(), and any moving around in the file structure in the dialog by the user causes the current working directory to change (using chdir()). Modified: branches/bieri_gui/gui_bieri/filedialog.py Modified: branches/bieri_gui/gui_bieri/filedialog.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/filedialog.py?rev=10374&r1=10373&r2=10374&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/filedialog.py (original) +++ branches/bieri_gui/gui_bieri/filedialog.py Tue Jan 26 13:45:24 2010 @@ -23,6 +23,8 @@ # file dialog script +# Python module imports. +from os import chdir, getcwd import wx @@ -54,17 +56,15 @@ return newdir -def openfile(msg, directory, filetype, default): +def openfile(msg, filetype, default): """Open a file. - For example to open /usr/save.relaxGUI, where the supported files to open are: *.relaxGUI, *.*: - openfile('select file to open', '/usr', 'save.relaxGUI', 'relaxGUI files (*.relaxGUI)|*.relaxGUI|all files (*.*)|*.*') + For example to open save.relaxGUI, where the supported files to open are: *.relaxGUI, *.*: + openfile('select file to open', 'save.relaxGUI', 'relaxGUI files (*.relaxGUI)|*.relaxGUI|all files (*.*)|*.*') @param msg: The message to display. @type msg: str - @param directory: The directory to open in. - @type directory: str @param filetype: The file to default selection to. @type filetype: str @param default: A list of supported files, indicated as "(Label)|os command|... @@ -72,10 +72,13 @@ """ # Open the dialog. - dialog = wx.FileDialog(None, message=msg, style=wx.OPEN, defaultDir=directory, defaultFile=filetype, wildcard=default) + dialog = wx.FileDialog(None, message=msg, style=wx.OPEN, defaultDir=getcwd(), defaultFile=filetype, wildcard=default) # A file was selected. if dialog.ShowModal() == wx.ID_OK: + # Change the current working directory. + chdir(dialog.GetDirectory()) + # Return the full file path. return dialog.GetPath()