Changeset 4270


Ignore:
Timestamp:
Jan 31, 2020 4:07:00 AM (21 months ago)
Author:
vondreele
Message:

set default directories to G2frame.LastGPXdir or result from GetImportPath? or GetExportPath? in most FileDialogs?
It is never None; ultimate default is '.' with a printed message - shouldn't happen
Set self.LastGPXdir to location of gpx file anytime GSAS-II reads it to start that project.
It should never be None or '.'.
Remove RMCProfile patches - shouldn't be needed now.
Make sure RMCProfile data files are local to the gpx file - required for running RMCProfile

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r4041 r4270  
    15721572       
    15731573    def getTextFile():
    1574         dlg = wx.FileDialog(G2frame,'Choose rigid body text file', '.', '',
     1574        dlg = wx.FileDialog(G2frame,'Choose rigid body text file', G2frame.LastGPXdir, '',
    15751575            "GSAS-II text file (*.txt)|*.txt|XYZ file (*.xyz)|*.xyz|"
    15761576            "Sybyl mol2 file (*.mol2)|*.mol2|PDB file (*.pdb;*.ent)|*.pdb;*.ent",
  • trunk/GSASIIctrlGUI.py

    r4220 r4270  
    31623162def GetImportPath(G2frame):
    31633163    '''Determines the default location to use for importing files. Tries sequentially
    3164     G2frame.TutorialImportDir, config var Import_directory and G2frame.LastImportDir.
     3164    G2frame.TutorialImportDir, config var Import_directory, G2frame.LastImportDir
     3165    and G2frame.LastGPXdir
    31653166   
    3166     :returns: a string containing the path to be used when reading files or None
     3167    :returns: a string containing the path to be used when reading files or '.'
    31673168      if none of the above are specified.
    31683169    '''
     
    31853186        elif GSASIIpath.GetConfigValue('debug'):
    31863187            print('DBG_Warning: G2frame.LastImportDir not found = '+G2frame.LastImportDir)
    3187     return None
     3188    elif G2frame.LastGPXdir:
     3189        return G2frame.LastGPXdir
     3190    print('Import path not found - set to current directory')      #now shouldn't happen
     3191    return '.'
    31883192
    31893193def GetExportPath(G2frame):
     
    31983202    elif G2frame.LastGPXdir:
    31993203        return G2frame.LastGPXdir
    3200     else:
    3201         return '.'
     3204    print('Export path not found - set to current directory')      #now shouldn't happen
     3205    return '.'
     3206
    32023207
    32033208################################################################################
  • trunk/GSASIIdataGUI.py

    r4249 r4270  
    38433843        if os.path.exists(f):
    38443844            self.OnFileOpen(event, filename=f)
     3845            self.LastGPXdir = dirname
    38453846        else:
    38463847            print('file not found',f)       
     
    38853886                self.GSASprojectfile = dlg.GetPath()
    38863887                self.GSASprojectfile = G2IO.FileDlgFixExt(dlg,self.GSASprojectfile)
    3887                 self.dirname = dlg.GetDirectory()
     3888                self.LastGPXdir = dlg.GetDirectory()
    38883889            finally:
    38893890                dlg.Destroy()
     
    40154016                GSASprojectfile = dlg.GetPath()
    40164017                GSASprojectfile = G2IO.FileDlgFixExt(dlg,GSASprojectfile)
     4018                self.LastGPXdir = dlg.GetDirectory()
    40174019        finally:
    40184020            dlg.Destroy()
  • trunk/GSASIIphsGUI.py

    r4269 r4270  
    4242import random as ran
    4343import subprocess as subp
     44import distutils.file_util as disfile
    4445import GSASIIpath
    4546GSASIIpath.SetVersionNumber("$Revision$")
     
    44734474            RMCPdict = data['RMC']['RMCProfile']
    44744475#patches
    4475             if 'runTimes' not in RMCPdict:
    4476                 RMCPdict['runTimes'] = [10.0,1.0]
    4477             lenA = len(RMCPdict['atSeq'])
    4478             if 'Oxid' not in RMCPdict:
    4479                 RMCPdict['Oxid'] = [[atmdata.BVSoxid[atm][0],0.001] for atm in RMCPdict['atSeq']]
    4480             Pairs= []
    4481             for pair in [[' %s-%s'%(RMCPdict['atSeq'][i],RMCPdict['atSeq'][j]) for j in range(i,lenA)] for i in range(lenA)]:
    4482                 Pairs += pair
    4483             RMCPdict['Pairs'] = dict(zip(Pairs,[RMCPdict['Pairs'].get(pair,[0.0,0.0,0.0]) for pair in Pairs]))
    4484             BVSpairs = []
    4485             if 'BVS' not in RMCPdict:
    4486                 RMCPdict['useBVS'] = False
    4487                 RMCPdict['BVS'] = {}
    4488             if lenA > 1:
    4489                 for pair in [[' %s-%s'%(RMCPdict['atSeq'][i],RMCPdict['atSeq'][j]) for j in range(i+1,lenA)] for i in range(lenA)]:
    4490                     BVSpairs += pair
    4491                 RMCPdict['BVS'] = dict(zip(BVSpairs,[RMCPdict['BVS'].get(pair,[0.0,0.0,0.0]) for pair in BVSpairs]))
    4492             if 'FxCN' not in RMCPdict:
    4493                 RMCPdict.update({'AveCN':[],'FxCN':[]})
    4494             if 'Potentials' not in RMCPdict:
    4495                 RMCPdict.update({'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],'Stretch search':10.,'Pot. Temp.':300.,}})
    4496             if 'Pot. Temp.' not in RMCPdict['Potentials']:
    4497                 RMCPdict['Potentials']['Pot. Temp.'] = 300.
    4498             if 'Swaps' not in RMCPdict:
    4499                 RMCPdict['Swaps'] = []
     4476#            if 'runTimes' not in RMCPdict:
     4477#                RMCPdict['runTimes'] = [10.0,1.0]
     4478#            lenA = len(RMCPdict['atSeq'])
     4479#            if 'Oxid' not in RMCPdict:
     4480#                RMCPdict['Oxid'] = [[atmdata.BVSoxid[atm][0],0.001] for atm in RMCPdict['atSeq']]
     4481#            Pairs= []
     4482#            for pair in [[' %s-%s'%(RMCPdict['atSeq'][i],RMCPdict['atSeq'][j]) for j in range(i,lenA)] for i in range(lenA)]:
     4483#                Pairs += pair
     4484#            RMCPdict['Pairs'] = dict(zip(Pairs,[RMCPdict['Pairs'].get(pair,[0.0,0.0,0.0]) for pair in Pairs]))
     4485#            BVSpairs = []
     4486#            if 'BVS' not in RMCPdict:
     4487#                RMCPdict['useBVS'] = False
     4488#                RMCPdict['BVS'] = {}
     4489#            if lenA > 1:
     4490#                for pair in [[' %s-%s'%(RMCPdict['atSeq'][i],RMCPdict['atSeq'][j]) for j in range(i+1,lenA)] for i in range(lenA)]:
     4491#                    BVSpairs += pair
     4492#                RMCPdict['BVS'] = dict(zip(BVSpairs,[RMCPdict['BVS'].get(pair,[0.0,0.0,0.0]) for pair in BVSpairs]))
     4493#            if 'FxCN' not in RMCPdict:
     4494#                RMCPdict.update({'AveCN':[],'FxCN':[]})
     4495#            if 'Potentials' not in RMCPdict:
     4496#                RMCPdict.update({'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],'Stretch search':10.,'Pot. Temp.':300.,}})
     4497#            if 'Pot. Temp.' not in RMCPdict['Potentials']:
     4498#                RMCPdict['Potentials']['Pot. Temp.'] = 300.
     4499#            if 'Swaps' not in RMCPdict:
     4500#                RMCPdict['Swaps'] = []
    45004501#end patches
    45014502               
     
    45124513                Obj = event.GetEventObject()
    45134514                fil = Indx[Obj.GetId()]
    4514                 dlg = wx.FileDialog(G2frame.FRMC, 'Choose '+fil+'NB: do not change directory; must be a local file',
    4515                     '.',style=wx.FD_OPEN,wildcard=fil+'(*.*)|*.*')
     4515                dlg = wx.FileDialog(G2frame.FRMC, 'Choose '+fil,G2G.GetImportPath(G2frame),
     4516                    style=wx.FD_OPEN ,wildcard=fil+'(*.*)|*.*')
    45164517                if dlg.ShowModal() == wx.ID_OK:
    4517                     fName = os.path.split(dlg.GetPath())[1]
     4518                    fpath,fName = os.path.split(dlg.GetPath())
     4519                    disfile.copy_file(dlg.GetPath(),os.path.join(G2G.GetImportPath(G2frame),fName))
    45184520                    if os.path.exists(fName):
    45194521                        RMCPdict['files'][fil][0] = fName
     
    49764978                Indx[filSel.GetId()] = fil
    49774979                fileSizer.Add(filSel,0,WACV)
    4978                 if RMCPdict['files'][fil][0]:
     4980                Rfile = RMCPdict['files'][fil][0]
     4981                if Rfile and os.path.exists(Rfile): #incase .gpx file is moved away from G(R), F(Q), etc. files
    49794982                    nform = 3
    49804983                    if 'Xray' in fil: nform = 1
     
    49854988                    fileSizer.Add(fileFormat,0,WACV)
    49864989                    fileSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['files'][fil],1),0,WACV)
    4987                 if not RMCPdict['files'][fil][0]:
     4990                else:
     4991                    RMCPdict['files'][fil][0] = ''
    49884992                    fileSizer.Add((5,5),0)
    49894993                    fileSizer.Add((5,5),0)
     
    50835087        global runFile
    50845088        if G2frame.RMCchoice == 'fullrmc':
    5085             dlg = wx.FileDialog(G2frame, 'Choose fullrmc run file to open', '.', runFile,
     5089            dlg = wx.FileDialog(G2frame, 'Choose fullrmc run file to open', G2G.GetImportPath(G2frame), runFile,
    50865090                wildcard='fullrmc run.py file (*.py)|*.py',style=wx.FD_OPEN| wx.FD_CHANGE_DIR)
    50875091        try:
     
    50995103        global runFile
    51005104        if G2frame.RMCchoice == 'fullrmc':
    5101             dlg = wx.FileDialog(G2frame, 'Choose fullrmc run.py file to save',  '.', runFile,
     5105            dlg = wx.FileDialog(G2frame, 'Choose fullrmc run.py file to save',  G2G.GetImportPath(G2frame), runFile,
    51025106                wildcard='fullrmc run.py file (*.py)|*.py',style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
    51035107        try:
     
    51225126      B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111.
    51235127      doi: https://doi.org/10.1002/jcc.24304''',caption='fullrmc',style=wx.ICON_INFORMATION)
    5124             dlg = wx.FileDialog(G2frame, 'Choose fullrmc python file to execute',
     5128            dlg = wx.FileDialog(G2frame, 'Choose fullrmc python file to execute', G2G.GetImportPath(G2frame),
    51255129                wildcard='fullrmc python file (*.py)|*.py',style=wx.FD_CHANGE_DIR)
    51265130            try:
     
    51495153            wx.MessageBox(''' For use of RMCProfile, please cite:
    51505154      RMCProfile: Reverse Monte Carlo for polycrystalline materials,
    5151       M.G. Tucker, D.A. keen, M.T. Dove, A.L. Goodwin and Q. Hui,
    5152       Jour. Phys.: Cond. matter 2007, 19, 335218.
     5155      M.G. Tucker, D.A. Keen, M.T. Dove, A.L. Goodwin and Q. Hui,
     5156      Jour. Phys.: Cond. Matter 2007, 19, 335218.
    51535157      doi: https://doi.org/10.1088/0953-8984/19/33/335218''',
    51545158      caption='RMCProfile',style=wx.ICON_INFORMATION)
     5159            if os.path.isfile(pName+'.his6f'):
     5160                os.remove(pName+'.his6f')
    51555161            if os.path.isfile(pName+'.neigh'):
    51565162                os.remove(pName+'.neigh')
     
    51875193            pName = generalData['Name'].replace(' ','_')
    51885194            dlg = wx.FileDialog(G2frame, "Choose any RMCProfile csv results file for "+pName+":",
    5189                 style=wx.FD_CHANGE_DIR,wildcard='RMCProfile result csv files|'+pName+'*.csv')
     5195                defaultDir=G2G.GetImportPath(G2frame),style=wx.FD_CHANGE_DIR,wildcard='RMCProfile result csv files|'+pName+'*.csv')
    51905196            if dlg.ShowModal() == wx.ID_OK:
    51915197                path = os.path.split(dlg.GetPath())[0]
     
    54765482               
    54775483        def OnImportLayer(event):
    5478             dlg = wx.FileDialog(G2frame, 'Choose GSAS-II project file',
     5484            dlg = wx.FileDialog(G2frame, 'Choose GSAS-II project file', G2G.GetImportPath(G2frame),
    54795485                wildcard='GSAS-II project file (*.gpx)|*.gpx',style=wx.FD_OPEN| wx.FD_CHANGE_DIR)
    54805486            try:
     
    59325938       
    59335939    def OnCopyPhase(event):
    5934         dlg = wx.FileDialog(G2frame, 'Choose GSAS-II project file',
     5940        dlg = wx.FileDialog(G2frame, 'Choose GSAS-II project file', G2G.GetImportPath(G2frame),
    59355941            wildcard='GSAS-II project file (*.gpx)|*.gpx',style=wx.FD_OPEN| wx.FD_CHANGE_DIR)
    59365942        try:
     
    59625968            finally:
    59635969                dlg.Destroy()
    5964         dlg = wx.FileDialog(G2frame, 'Choose DIFFaX file name to read', '.', '',
     5970        dlg = wx.FileDialog(G2frame, 'Choose DIFFaX file name to read', G2G.GetImportPath(G2frame), '',
    59655971            'DIFFaX file (*.*)|*.*',style=wx.FD_OPEN | wx.FD_CHANGE_DIR)
    59665972        try:
  • trunk/GSASIIplot.py

    r4268 r4270  
    54325432        elif event.key == 's':
    54335433            # write the function values (not peaks) onto a file
    5434             dlg = wx.FileDialog(G2frame, 'Choose CSV file to write',
     5434            dlg = wx.FileDialog(G2frame, 'Choose CSV file to write', G2G.GetExportPath(G2frame),
    54355435                    wildcard='column-separated file (*.csv)|.csv',
    54365436                    style=wx.FD_CHANGE_DIR|wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
     
    79897989                Fname = (os.path.splitext(projFile)[0]+'.'+mode).replace('*','+')
    79907990            else:
    7991                 dlg = wx.FileDialog(G2frame, 'Choose graphics save file',
     7991                dlg = wx.FileDialog(G2frame, 'Choose graphics save file',G2G.GetExportPath(G2frame),
    79927992                    wildcard='Graphics file (*.'+mode+')|*.'+mode,style=wx.FD_OPEN| wx.FD_CHANGE_DIR)
    79937993                try:
  • trunk/GSASIIpwd.py

    r4269 r4270  
    23532353    fl.write('INPUT_CONFIGURATION_FORMAT ::  rmc6f\n')
    23542354    fl.write('SAVE_CONFIGURATION_FORMAT  ::  rmc6f\n')
     2355    fl.write('IGNORE_HISTORY_FILE ::\n')
    23552356    fl.write('\n')
    23562357    fl.write('DISTANCE_WINDOW ::\n')
Note: See TracChangeset for help on using the changeset viewer.