mailr10377 - /branches/bieri_gui/gui_bieri/filedialog.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 26, 2010 - 13:52:
Author: bugman
Date: Tue Jan 26 13:52:32 2010
New Revision: 10377

URL: http://svn.gna.org/viewcvs/relax?rev=10377&view=rev
Log:
The current working directory is used and changed if no directory arg is 
supplied to openfile().


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=10377&r1=10376&r2=10377&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/filedialog.py (original)
+++ branches/bieri_gui/gui_bieri/filedialog.py Tue Jan 26 13:52:32 2010
@@ -23,6 +23,8 @@
 
 # file dialog script
 
+# Python module imports.
+from os import chdir, getcwd
 import wx
 
 
@@ -71,11 +73,21 @@
     @type default:      str
     """
 
+    # The current working directory.
+    dir_switch = False
+    if directory == None:
+        directory = getcwd()
+        dir_switch = True
+
     # Open the dialog.
     dialog = wx.FileDialog(None, message=msg, style=wx.OPEN, 
defaultDir=directory, defaultFile=filetype, wildcard=default)
 
     # A file was selected.
     if dialog.ShowModal() == wx.ID_OK:
+        # Reset the current working directory if changed.
+        if dir_switch:
+            chdir(dialog.GetDirectory())
+
         # Return the full file path.
         return dialog.GetPath()
 




Related Messages


Powered by MHonArc, Updated Tue Jan 26 14:00:02 2010