Changeset 2109 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Dec 26, 2015 10:22:09 PM (6 years ago)
Author:
toby
Message:

Andrey's enhancement: keep track of last GPX, import & export directories; optionally save the 1st two

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r2093 r2109  
    188188
    189189    if not os.path.exists(imagefile):
    190         dlg = wx.FileDialog(G2frame, 'Previous image file not found; open here', '.', '',\
    191         'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor;*.stl)\
    192         |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor;*.stl|\
    193         European detector file (*.edf)|*.edf|\
    194         Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|\
    195         MAR file (*.mar*)|*.mar*|\
    196         GE Image (*.ge*;*.avg;*.sum;*.cor)|*.ge*;*.avg;*.sum;*.cor|\
    197         ADSC Image (*.img)|*.img|\
    198         Rigaku-Axis4 (*.stl)|*.stl|\
    199         All files (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR)
     190        prevnam = os.path.split(imagefile)[1]
     191        prevext = os.path.splitext(imagefile)[1]
     192        wildcard = 'Image format (*'+prevext+')|*'+prevext
     193        dlg = wx.FileDialog(G2frame, 'Previous image file ('+prevnam+') not found; open here', '.', prevnam,
     194                            wildcard,wx.OPEN)
    200195        try:
    201196            dlg.SetFilename(''+ospath.split(imagefile)[1])
     
    867862                cPickle.dump(data,file,1)
    868863            file.close()
     864            pth = os.path.split(os.path.abspath(G2frame.GSASprojectfile))[0]
     865            if GSASIIpath.GetConfigValue('Save_paths'): G2G.SaveGPXdirectory(pth)
     866            G2frame.LastGPXdir = pth
    869867        finally:
    870868            wx.EndBusyCursor()
     
    21912189        :returns: a file name (str) or None if Cancel is pressed
    21922190        '''
     2191       
     2192        pth = G2G.GetExportPath(self.G2frame)
    21932193        defnam = os.path.splitext(
    21942194            os.path.split(self.G2frame.GSASprojectfile)[1]
    21952195            )[0]+self.extension
    21962196        dlg = wx.FileDialog(
    2197             self.G2frame, 'Input name for file to write', '.', defnam,
     2197            self.G2frame, 'Input name for file to write', pth, defnam,
    21982198            self.longFormatName+' (*'+self.extension+')|*'+self.extension,
    2199             wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     2199            wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
    22002200        dlg.CenterOnParent()
    22012201        try:
    22022202            if dlg.ShowModal() == wx.ID_OK:
    22032203                filename = dlg.GetPath()
    2204                 # make sure extension is correct
    2205                 filename = os.path.splitext(filename)[0]+self.extension
     2204                self.G2frame.LastExportDir = os.path.split(filename)[0]
     2205                filename = os.path.splitext(filename)[0]+self.extension # make sure extension is correct
    22062206            else:
    22072207                filename = None
     
    22162216        :returns: a directory name (str) or None if Cancel is pressed
    22172217        '''
    2218         if self.G2frame.exportDir:
    2219             startdir = self.G2frame.exportDir
    2220         elif self.G2frame.GSASprojectfile:
    2221             startdir = os.path.split(self.G2frame.GSASprojectfile)[0]
    2222         elif self.G2frame.dirname:
    2223             startdir = self.G2frame.dirname
    2224         else:
    2225             startdir = ''
     2218        pth = G2G.GetExportPath(self.G2frame)
    22262219        dlg = wx.DirDialog(
    2227             self.G2frame, 'Input directory where file(s) will be written', startdir,
     2220            self.G2frame, 'Input directory where file(s) will be written', pth,
    22282221            wx.DD_DEFAULT_STYLE)
    22292222        dlg.CenterOnParent()
     
    22312224            if dlg.ShowModal() == wx.ID_OK:
    22322225                filename = dlg.GetPath()
    2233                 self.G2frame.exportDir = filename
     2226                self.G2frame.LastExportDir = filename
    22342227            else:
    22352228                filename = None
Note: See TracChangeset for help on using the changeset viewer.