@@ -226,13 +226,14 @@ def OnFileSel(event):
226226 style = wx .FD_OPEN ,wildcard = fil + '(*.*)|*.*' )
227227 if dlg .ShowModal () == wx .ID_OK :
228228 fpath ,fName = os .path .split (dlg .GetPath ())
229- if os .path .exists (fName ): # is there a file by this name in the current directory?
229+ if os .path .exists (os . path . join ( G2frame . LastGPXdir , fName ) ): # is there a file by this name in the current directory?
230230 RMCPdict ['files' ][fil ][0 ] = fName
231231 else : # nope, copy it
232232 # TODO: is G2frame.LastGPXdir the right choice here or
233233 # do I want the current working directory (same?)
234234 shutil .copy (dlg .GetPath (), os .path .join (G2frame .LastGPXdir ,fName ))
235- if not os .path .exists (fName ): # sanity check
235+ RMCPdict ['files' ][fil ][0 ] = fName
236+ if not os .path .exists (os .path .join (G2frame .LastGPXdir ,fName )): # sanity check
236237 print (f'Error: file { fName } not found in .gpx directory ({ G2frame .LastGPXdir } )' )
237238 return
238239 G2frame .LastImportDir = fpath #set so next file is found in same place
@@ -270,7 +271,7 @@ def OnPlotBtn(event):
270271 XY = np .empty ((1 ,2 ))
271272 while XY .shape [0 ] == 1 :
272273 try :
273- XY = np .loadtxt (fileItem [0 ],skiprows = start )
274+ XY = np .loadtxt (os . path . join ( G2frame . LastGPXdir , fileItem [0 ]) ,skiprows = start )
274275 except ValueError :
275276 start += 1
276277 if start > 500 : #absurd number of header lines!
@@ -551,7 +552,7 @@ def OnSetVal(event):
551552 if 'Xray' in fil :
552553 nform = 1
553554 Name = 'Xdata'
554- if Rfile and os .path .exists (Rfile ): #incase .gpx file is moved away from G(R), F(Q), etc. files
555+ if Rfile and os .path .exists (os . path . join ( G2frame . LastGPXdir , Rfile ) ): #incase .gpx file is moved away from G(R), F(Q), etc. files
555556 fileFormat = wx .ComboBox (G2frame .FRMC ,choices = Formats [:nform ],style = wx .CB_DROPDOWN | wx .TE_READONLY )
556557 fileFormat .SetStringSelection (RMCPdict ['files' ][fil ][3 ])
557558 Indx [fileFormat .GetId ()] = fil
0 commit comments