Ignore:
Timestamp:
Jun 21, 2021 11:32:01 AM (6 months ago)
Author:
toby
Message:

start work on option to move Phase/Data? to 1st level in tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4951 r4965  
    8686import GSASIIfpaGUI as G2fpa
    8787import GSASIIseqGUI as G2seq
     88import GSASIIddataGUI as G2ddG
    8889
    8990try:
     
    11481149            newPhaseList.append(PhaseName)
    11491150            print(u'Read phase {} from file {}'.format(PhaseName,self.lastimport))
    1150             if not GetGPXtreeItemId(self,self.root,'Phases'):
    1151                 sub = self.GPXtree.AppendItem(parent=self.root,text='Phases')
    1152             else:
    1153                 sub = GetGPXtreeItemId(self,self.root,'Phases')
     1151            sub = FindPhaseItem(self)
    11541152            psub = self.GPXtree.AppendItem(parent=sub,text=PhaseName)
    11551153            self.GPXtree.SetItemPyData(psub,rd.Phase)
     
    39403938    def OnAddPhase(self,event):
    39413939        'Add a new, empty phase to the tree. Called by Data/Add Phase menu'
    3942         self.CheckNotebook()
    3943         if not GetGPXtreeItemId(self,self.root,'Phases'):
    3944             sub = self.GPXtree.AppendItem(parent=self.root,text='Phases')
    3945         else:
    3946             sub = GetGPXtreeItemId(self,self.root,'Phases')
    39473940        PhaseName = ''
    39483941        dlg = wx.TextEntryDialog(None,'Enter a name for this phase','Phase Name Entry','New phase',
     
    39503943        if dlg.ShowModal() == wx.ID_OK:
    39513944            PhaseName = dlg.GetValue()
    3952         dlg.Destroy()
     3945            self.CheckNotebook()
     3946            sub = FindPhaseItem(self)
     3947            dlg.Destroy()
     3948        else:
     3949            dlg.Destroy()
     3950            return
    39533951        if not GetGPXtreeItemId(self,self.root,'Restraints'):
    39543952            subr = self.GPXtree.AppendItem(parent=self.root,text='Restraints')
     
    75757573            G2frame.dataWindow.GetSizer().Add(
    75767574                wx.StaticText(G2frame.dataWindow,wx.ID_ANY,'Select one phase to see its restraints'))
     7575        elif G2frame.GPXtree.GetItemText(item).startswith('Hist/Phase '):
     7576            #import imp
     7577            #imp.reload(G2ddG)
     7578            G2ddG.MakeHistPhaseWin(G2frame)
     7579        elif GSASIIpath.GetConfigValue('debug'):
     7580            print('Unknown tree item',G2frame.GPXtree.GetItemText(item))
    75777581    ############################################################################
    75787582    # process second-level entries in tree           
     
    77867790    else:
    77877791        G2frame.SetMenuBar(menu)
    7788 
     7792       
     7793def FindPhaseItem(G2frame):
     7794    '''Finds the Phase item in the tree. If not present it adds one
     7795    also adding 'Hist/Phase Params' if config var SeparateHistPhaseTreeItem
     7796    is set as True.
     7797    '''
     7798    if not GetGPXtreeItemId(G2frame,G2frame.root,'Phases'):
     7799        sub = G2frame.GPXtree.AppendItem(parent=G2frame.root,text='Phases')
     7800        if GSASIIpath.GetConfigValue('SeparateHistPhaseTreeItem',False):
     7801            G2frame.GPXtree.AppendItem(parent=G2frame.root,text='Hist/Phase Params')
     7802    else:
     7803        sub = GetGPXtreeItemId(G2frame,G2frame.root,'Phases')
     7804    return sub
     7805       
    77897806if __name__ == '__main__':
    77907807    ShowVersions()
Note: See TracChangeset for help on using the changeset viewer.