Skip to content

Commit 05670c6

Browse files
committed
fix RMCProfile issues on macos
1 parent dbb1a02 commit 05670c6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

GSASII/GSASIIphsGUI.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6388,8 +6388,12 @@ def RunRMCProfile(event):
63886388
ascript_file = os.path.join(os.getcwd(), "runrmc.script")
63896389
with open(ascript_file, 'w') as f:
63906390
f.write('tell application "Terminal"\n')
6391-
f.write(f''' do script "echo 'Running RMCprofile'"\n''')
6391+
f.write(' if not (exists window 1) then\n')
6392+
f.write(f' do script "bash {script_file}"\n')
6393+
f.write(' else\n')
63926394
f.write(f' do script "bash {script_file}" in window 1\n')
6395+
f.write(' end if\n')
6396+
f.write(' activate\n')
63936397
f.write("end tell\n")
63946398
subp.Popen(['osascript', ascript_file])
63956399
elif sys.platform.startswith("linux"):
@@ -6607,8 +6611,12 @@ def OnViewRMC(event):
66076611
generalData = data['General']
66086612
RMCPdict = data['RMC']['RMCProfile']
66096613
pName = generalData['Name'].replace(' ','_')
6614+
if sys.platform == "darwin":
6615+
wildcard = 'RMCProfile result csv files|' + pName + '*.csv' + '|All files|*.*'
6616+
else:
6617+
wildcard = 'RMCProfile result csv files|' + pName + '*.csv'
66106618
dlg = wx.FileDialog(G2frame, "Choose any RMCProfile csv results file for "+pName+":",
6611-
defaultDir=G2frame.LastGPXdir,style=wx.FD_CHANGE_DIR,wildcard='RMCProfile result csv files|'+pName+'*.csv')
6619+
defaultDir=G2frame.LastGPXdir,style=wx.FD_CHANGE_DIR,wildcard=wildcard)
66126620
if dlg.ShowModal() == wx.ID_OK:
66136621
path = os.path.split(dlg.GetPath())[0]
66146622
dlg.Destroy()

GSASII/GSASIIrmcGUI.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -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

Comments
 (0)