Changeset 4893 for trunk/GSASIIfpaGUI.py


Ignore:
Timestamp:
Apr 24, 2021 1:27:16 PM (7 months ago)
Author:
toby
Message:

FPA: add extra Save button (perhaps original should be removed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIfpaGUI.py

    r4892 r4893  
    131131    if (not IBmono) and len(parmDict['wave']) == 4:
    132132        SetCu5Wave()
    133    
     133
     134def writeNIST(filename):
     135    '''Write the NIST FPA terms into a JSON-like file that can be reloaded
     136    in _onReadFPA
     137    '''
     138    if not filename: return
     139   
     140    fp = open(filename,'w')
     141    fp.write('# parameters to be used in the NIST XRD Fundamental Parameters program\n')
     142    fp.write('{\n')
     143    for key in sorted(NISTparms):
     144        fp.write("   '"+key+"' : "+str(NISTparms[key])+",")
     145        if not key: fp.write('  # global parameters')
     146        fp.write('\n')
     147    fp.write('}\n')
     148    fp.close()
     149       
    134150#SetCu2Wave() # use these as default
    135151SetCu5Wave() # use these as default
     
    266282                     labelY=r'Intensity (arbitrary)',
    267283                     Title='FPA peak', newPlot=True, lines=True)
     284    def _onSaveFPA(event):
     285        filename = G2G.askSaveFile(G2frame,'','.NISTfpa',
     286                                       'dict of NIST FPA values',FPdlg)
     287        writeNIST(filename)
    268288
    269289    if FPdlg.GetSizer(): FPdlg.GetSizer().Clear(True)
     
    345365    ctrl = G2G.ValidatedTxtCtrl(FPdlg,simParms,'plotpos',size=(70,-1))
    346366    btnsizer.Add(ctrl)
    347     btnsizer.Add(wx.StaticText(FPdlg,wx.ID_ANY,' deg.'))   
     367    btnsizer.Add(wx.StaticText(FPdlg,wx.ID_ANY,' deg.  '))   
     368    saveBtn = wx.Button(FPdlg, wx.ID_ANY,'Save FPA dict')
     369    btnsizer.Add(saveBtn)
     370    saveBtn.Bind(wx.EVT_BUTTON,_onSaveFPA)
    348371    MainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER, 0)
    349372    MainSizer.Add((-1,4))
     
    688711        filename = G2G.askSaveFile(G2frame,'','.NISTfpa',
    689712                                       'dict of NIST FPA values',dlg)
    690         if not filename: return
    691         fp = open(filename,'w')
    692         fp.write('# parameters to be used in the NIST XRD Fundamental Parameters program\n')
    693         fp.write('{\n')
    694         for key in sorted(NISTparms):
    695             fp.write("   '"+key+"' : "+str(NISTparms[key])+",")
    696             if not key: fp.write('  # global parameters')
    697             fp.write('\n')
    698         fp.write('}\n')
    699         fp.close()
     713        writeNIST(filename)
     714       
    700715    def _onReadFPA(event):
    701716        filename = G2G.GetImportFile(G2frame,
Note: See TracChangeset for help on using the changeset viewer.