@@ -732,6 +732,7 @@ def get_filechooser(self):
732732 fc = FileChooserDialog (
733733 title = 'Save the figure' ,
734734 parent = self .win ,
735+ path = os .path .expanduser (rcParams .get ('savefig.directory' , '' )),
735736 filetypes = self .canvas .get_supported_filetypes (),
736737 default_filetype = self .canvas .get_default_filetype ())
737738 fc .set_current_name (self .canvas .get_default_filename ())
@@ -740,6 +741,13 @@ def get_filechooser(self):
740741 def save_figure (self , * args ):
741742 fname , format = self .get_filechooser ().get_filename_from_user ()
742743 if fname :
744+ startpath = os .path .expanduser (rcParams .get ('savefig.directory' , '' ))
745+ if startpath == '' :
746+ # explicitly missing key or empty str signals to use cwd
747+ rcParams ['savefig.directory' ] = startpath
748+ else :
749+ # save dir for next time
750+ rcParams ['savefig.directory' ] = os .path .dirname (unicode (fname ))
743751 try :
744752 self .canvas .print_figure (fname , format = format )
745753 except Exception as e :
@@ -1010,8 +1018,8 @@ def save_figure(self, *args):
10101018
10111019
10121020class FileChooserDialog (gtk .FileChooserDialog ):
1013- """GTK+ 2.4 file selector which remembers the last file/directory
1014- selected and presents the user with a menu of supported image formats
1021+ """GTK+ 2.4 file selector which presents the user with a menu
1022+ of supported image formats
10151023 """
10161024 def __init__ (self ,
10171025 title = 'Save file' ,
0 commit comments