Changeset 3193 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
Dec 15, 2017 9:59:48 AM (4 years ago)
Author:
toby
Message:

better error msg w/o calibrant; search comments when Sample Parameters FreePrm? label is changed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r3191 r3193  
    23442344        wx.CallAfter(UpdateSampleGrid,G2frame,data)
    23452345       
     2346    def SearchAllComments(value,tc,*args,**kwargs):
     2347        '''Called when the label for a FreePrm is changed: the comments for all PWDR
     2348        histograms are searched for a "label=value" pair that matches the label (case
     2349        is ignored) and the values are then set to this value, if it can be converted
     2350        to a float.
     2351        '''
     2352        id, cookie = G2frame.GPXtree.GetFirstChild(G2frame.root)
     2353        while id:
     2354            name = G2frame.GPXtree.GetItemText(id)
     2355            if 'PWDR' in name:
     2356                Comments = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,id,'Comments'))
     2357                Sample =   G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,id, 'Sample Parameters'))
     2358                for i,item in enumerate(Comments):
     2359                    itemSp = item.split('=')
     2360                    if value.lower() == itemSp[0].lower():
     2361                        try:
     2362                            Sample[tc.key] = float(itemSp[1])
     2363                        except:
     2364                            print('"{}" has an invalid value in Comments from {}'
     2365                                  .format(item.strip(),name))
     2366            id, cookie = G2frame.GPXtree.GetNextChild(G2frame.root, cookie)
     2367        wx.CallLater(100,UpdateSampleGrid,G2frame,data)
     2368       
     2369       
    23462370    ######## DEBUG #######################################################
    23472371    #import GSASIIpwdGUI
     
    24642488        parmSizer.Add(parmVal,0,WACV)
    24652489    Info = {}
    2466        
     2490   
    24672491    for key in ('FreePrm1','FreePrm2','FreePrm3'):
    24682492        parmVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,Controls,key,typeHint=str,
    2469                                         notBlank=False)
     2493                                        notBlank=False,OnLeave=SearchAllComments)
    24702494        parmSizer.Add(parmVal,1,wx.EXPAND)
    24712495        parmVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,key,typeHint=float)
Note: See TracChangeset for help on using the changeset viewer.