Changeset 2673


Ignore:
Timestamp:
Jan 30, 2017 10:05:43 AM (5 years ago)
Author:
vondreele
Message:

moved GetFileList? to top of G2pwdGUI - needed in two places. The one on GSASII doesn't seem to work & isn't used anywhere.
Put missing import of G2elem & tof2q lambda in G2imgGUI.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r2671 r2673  
    3030import GSASIIimage as G2img
    3131import GSASIImath as G2mth
     32import GSASIIElem as G2elem
    3233import GSASIIpwdGUI as G2pdG
    3334import GSASIIplot as G2plt
     
    4748asind = lambda x: 180.*math.asin(x)/math.pi
    4849tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w
     50tof2q = lambda t,C:2.0*math.pi*C/t
    4951atand = lambda x: 180.*math.atan(x)/math.pi
    5052atan2d = lambda y,x: 180.*math.atan2(y,x)/math.pi
     
    28262828                Qlimits = [0.9*qMax,qMax]
    28272829
    2828                 PWDRname = pwdr[4:]
    28292830                item = pwdr
    28302831                Comments = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
  • trunk/GSASIIpwdGUI.py

    r2670 r2673  
    212212    return {'Substances':{'vacuum':{'Elements':{},'Volume':1.0,'Density':0.0,'Scatt density':0.0}}}
    213213
     214def GetFileList(G2frame,fileType):
     215    fileList = []
     216    id, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)
     217    while id:
     218        name = G2frame.PatternTree.GetItemText(id)
     219        if fileType in name.split()[0]:
     220            fileList.append(name)
     221        id, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
     222    return fileList
     223       
    214224def GetHistsLikeSelected(G2frame):
    215225    '''Get the histograms that match the current selected one:
     
    47474757       
    47484758        item = data[key]
    4749         fileList = [''] + GetFileList('PWDR')
     4759        fileList = [''] + GetFileList(G2frame,'PWDR')
    47504760        fileSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' '+key+' file:'),0,WACV)
    47514761        fileName = wx.ComboBox(G2frame.dataDisplay,value=item['Name'],choices=fileList,
     
    48524862        wx.CallAfter(OnComputePDF,None)
    48534863
    4854     def GetFileList(fileType):
    4855         fileList = []
    4856         id, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)
    4857         while id:
    4858             name = G2frame.PatternTree.GetItemText(id)
    4859             if fileType in name.split()[0]:
    4860                 fileList.append(name)
    4861             id, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
    4862         return fileList
    4863        
    48644864    def OnCopyPDFControls(event):
    48654865        import copy
    4866         TextList = GetFileList('PDF')
     4866        TextList = GetFileList(G2frame,'PDF')
    48674867        Source = G2frame.PatternTree.GetItemText(G2frame.PatternId)
    48684868        if len(TextList) == 1:
     
    53215321        return peakBox
    53225322       
     5323    def OnCopyPDFPeaks(event):
     5324        import copy
     5325        TextList = GetFileList(G2frame,'PDF')
     5326        Source = G2frame.PatternTree.GetItemText(G2frame.PatternId)
     5327        if len(TextList) == 1:
     5328            G2frame.ErrorDialog('Nothing to copy controls to','There must be more than one "PDF" pattern')
     5329            return
     5330        dlg = G2G.G2MultiChoiceDialog(G2frame,'Copy PDF peaks','Copy peaks from '+Source+' to:',TextList)
     5331        try:
     5332            if dlg.ShowModal() == wx.ID_OK:
     5333                PDFlist = [TextList[i] for i in dlg.GetSelections()]
     5334                for item in PDFlist:
     5335                    id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item)
     5336                    olddata = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,id, 'PDF Peaks'))
     5337                    olddata.update(copy.deepcopy(peaks))
     5338                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,id, 'PDF Peaks'),olddata)
     5339                Status.SetStatusText('PDF peaks copied')
     5340        finally:
     5341            dlg.Destroy()
     5342       
     5343    def OnFitPDFpeaks(event):
     5344        print 'fit peaks'
     5345       
     5346    def OnFitAllPDFpeaks(event):
     5347        print 'fit all pdf peaks'
     5348       
    53235349
    53245350    if G2frame.dataDisplay:
     
    53285354        Status = G2frame.dataFrame.CreateStatusBar()   
    53295355    G2frame.dataDisplay = wx.Panel(G2frame.dataFrame)
    5330 #    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopyPDFControls, id=G2gd.wxID_PDFCOPYCONTROLS)
    5331 #    G2frame.dataFrame.Bind(wx.EVT_MENU, OnSavePDFControls, id=G2gd.wxID_PDFSAVECONTROLS)
     5356    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopyPDFPeaks, id=G2gd.wxID_PDFCOPYPEAKS)
     5357    G2frame.dataFrame.Bind(wx.EVT_MENU, OnFitPDFpeaks, id=G2gd.wxID_PDFPKSFIT)
     5358    G2frame.dataFrame.Bind(wx.EVT_MENU, OnFitAllPDFpeaks, id=G2gd.wxID_PDFPKSFITALL)
    53325359    mainSizer = wx.BoxSizer(wx.VERTICAL)
    53335360    mainSizer.Add((5,5),0)
     
    53435370    G2frame.dataDisplay.SetSizer(mainSizer)
    53445371    Size = mainSizer.Fit(G2frame.dataFrame)
    5345     Size = (500,300)
    53465372    G2frame.dataFrame.setSizePosLeft(Size)
    53475373   
Note: See TracChangeset for help on using the changeset viewer.