Changeset 4801 for trunk/G2compare.py


Ignore:
Timestamp:
Feb 5, 2021 10:14:23 PM (9 months ago)
Author:
toby
Message:

Cleanup deleted hists in Phase/data; improve help button location; mac: use default browser for help; G2compare filter projects by histogram

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/G2compare.py

    r4785 r4801  
    162162        item = File.Append(wx.ID_ANY,'&Import single project...\tCtrl+O','Open a GSAS-II project file (*.gpx)')           
    163163        self.Bind(wx.EVT_MENU, self.onLoadGPX, id=item.GetId())
    164         item = File.Append(wx.ID_ANY,'&Import multiple projects...\tCtrl+M','Open a GSAS-II project file (*.gpx)')           
     164        item = File.Append(wx.ID_ANY,'&Import multiple projects...\tCtrl+U','Open a GSAS-II project file (*.gpx)')
    165165        self.Bind(wx.EVT_MENU, self.onLoadMultGPX, id=item.GetId())
    166166        item = File.Append(wx.ID_ANY,'&Wildcard import of projects...\tCtrl+W','Open a GSAS-II project file (*.gpx)')           
     
    177177                                                 'Display {}s'.format(m))
    178178            self.Bind(wx.EVT_MENU, self.onRefresh, id=item.GetId())
    179         item = self.Mode.Append(wx.ID_ANY,'Set histogram filter','Set a filter for histograms to display')
    180         self.Bind(wx.EVT_MENU, self.onHistFilter, id=item.GetId())
     179        self.hFilter = self.Mode.Append(wx.ID_ANY,'Filter by histogram\tCtrl+F','Only show selected histograms')
     180        self.Bind(wx.EVT_MENU, self.onHistFilter, id=self.hFilter.GetId())
    181181        modeMenu = wx.Menu(title='')
    182182        self.MenuBar.Append(menu=modeMenu, title='TBD')
    183183        self.modeMenuPos = self.MenuBar.FindMenu('TBD')
    184         #item = modeMenu.Append(wx.ID_ANY,'test') # menu can't be empty
    185184       
    186185        Frame.SetMenuBar(self.MenuBar)
     
    227226
    228227        self.fileList = []  # list of files read for use in Reload
    229         self.histList = []  # list of histograms loaded for unique naming
     228        self.histListOrg = [] # list of histograms, before mods for unique naming
     229        self.histList = []  # list of histograms, after mods for unique naming
    230230        self.projList = []
    231231
     
    298298        self.GPXtree.DeleteChildren(self.root)  # delete tree contents
    299299        self.histList = []  # clear list of loaded histograms
     300        self.histListOrg = []
    300301        self.projList = []
     302        self.hFilter.Enable(not self.getMode() == "Phase") # Filter disabled for Phase display
    301303        for fil,mode in self.fileList:
    302304            self.loadFile(fil)
     
    410412                    break
    411413                if not data[0][0].startswith('PWDR'): continue
     414                self.histListOrg.append(data[0][0])
    412415                if self.PWDRfilter is not None: # implement filter
    413416                    if self.PWDRfilter not in data[0][0]: continue
     
    459462    def onHistFilter(self,event):
    460463        'Load a filter string via a dialog in response to a menu event'
    461         lbl = ''
     464        defval = ''
    462465        if self.PWDRfilter is not None:
    463             lbl = self.PWDRfilter
     466            defval = self.PWDRfilter
     467        uniqueHist = sorted(set(self.histListOrg))
    464468        dlg = G2G.SingleStringDialog(self,'Set string',
    465469                                'Set a string that must be in histogram name',
    466                                  lbl,size=(400,-1))
     470                                defval, choices=uniqueHist, size=(400,-1))
    467471        if dlg.Show():
    468472            if dlg.GetValue().strip() == '':
     
    550554        #Phases = None
    551555        #G2frame.GPXtree.SetItemPyData(Id,Covar[1])
     556        if self.PWDRfilter is None: # implement filter
     557            match = True
     558        else:
     559            match = False
     560        Covar = None
    552561        try:
    553562            while True:
     
    556565                except EOFError:
    557566                    break
    558                 #if data[0][0] == 'Controls' and 'LastSavedUsing' in data[0][1]:
     567                if data[0][0].startswith('PWDR'):
     568                    self.histListOrg.append(data[0][0])
     569                    if self.PWDRfilter is not None: # implement filter
     570                        if self.PWDRfilter in data[0][0]: match = True
    559571                if not data[0][0].startswith('Covariance'): continue
    560572                Covar = data[0]
     
    570582                        projInfo += ['?']
    571583                    f = '{:6.2f}'
    572                 #GSASIIpath.IPyBreak_base()
    573                 #if self.PWDRfilter is not None: # implement filter
    574                 #    if self.PWDRfilter not in data[0][0]: continue
    575584                Covar[0] = shortname # + ' Covariance'
     585            if match and Covar:
    576586                Id = G2frame.GPXtree.AppendItem(parent=G2frame.root,text=Covar[0])
    577587                G2frame.GPXtree.SetItemPyData(Id,Covar[1])
    578588                self.projList.append(projInfo)
    579                 break
    580             else:
    581                 print("{} does not have refinement results".format(shortname))
    582589        except Exception as errmsg:
    583590            if GSASIIpath.GetConfigValue('debug'):
     
    880887    GSASIIpath.InvokeDebugOpts()
    881888    Frame = main(application) # start the GUI
     889    loadall = False
    882890    argLoadlist = sys.argv[1:]
    883891    for arg in argLoadlist:
     
    886894            Frame.fileList.append([fil,'GPX'])
    887895            Frame.loadFile(fil)
     896        elif '-d' in arg:
     897            loadall = True
    888898        else:
    889899            print('File {} not found. Skipping'.format(fil))
    890900    Frame.doneLoad()
    891901    # debug code to select Project in initial mode
    892     #Frame.onLoadWildGPX(None,wildcard='*')
    893     #Frame.Mode.FindItemById(Frame.wxID_Mode['Project']).Check(True)
    894     #Frame.onRefresh(None)
     902    if loadall:
     903        Frame.onLoadWildGPX(None,wildcard='*')
     904        Frame.Mode.FindItemById(Frame.wxID_Mode['Project']).Check(True)
     905        Frame.onRefresh(None)
    895906   
    896907    application.MainLoop()
Note: See TracChangeset for help on using the changeset viewer.