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/GSASIIddataGUI.py

    r4846 r4965  
    10351035
    10361036    ######################################################################
    1037     ### Beginning of UpdateDData execution here
     1037    #### Beginning of UpdateDData execution here
    10381038    ######################################################################
    10391039    G2frame.SetStatusText('',1)
     
    10791079    mainSizer = wx.BoxSizer(wx.VERTICAL)
    10801080    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    1081     topSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Histogram data for '+PhaseName+':'),0,wx.LEFT,5)
     1081    topSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Histogram data for Phase '+PhaseName+':'),0,wx.LEFT,5)
    10821082    # add help button to bring up help web page - at right sede of window
    10831083    topSizer.Add((-1,-1),1,wx.EXPAND)
     
    11071107       
    11081108    G2phG.SetPhaseWindow(DData,mainSizer,Scroll=Scroll)
     1109
     1110def MakeHistPhaseWin(G2frame):
     1111    '''Display Phase/Data info from Hist/Phase tree item
     1112    '''
     1113    TabSelectionIdDict = {}
     1114    def OnSelectPage(event):
     1115        'Called when an item is selected from the Select page menu'
     1116        tabname = TabSelectionIdDict.get(event.GetId()) # lookup phase
     1117        if not tabname:
     1118            print ('Warning: menu item not in dict! id= %d'%event.GetId())
     1119            return
     1120        # find the tab matching the phase
     1121        for i,page in enumerate(phaseList):
     1122            if tabname == phaseList[i]:
     1123                HAPBook.SetSelection(i)
     1124                FillDDataWindow(i) # may result in a double paint on some OSs
     1125                return
     1126        else:
     1127            print ("Warning: tab "+tabname+" was not found")
     1128           
     1129    def OnPageChanged(event):
     1130        'respond to a notebook tab'
     1131        page = event.GetSelection()
     1132        FillDDataWindow(page)
     1133       
     1134    def FillDDataWindow(page):
     1135        'display the DData info'
     1136        G2frame.HistPhaseLastSel = phaseList[page]
     1137        data = G2frame.GPXtree.GetItemPyData(phaseIds[page])
     1138        G2plt.PlotSizeStrainPO(G2frame,data,hist='',Start=True)           
     1139        UpdateDData(G2frame,DData[page],data)
     1140
     1141    #### start of MakeHistPhaseWin
     1142    G2frame.dataWindow.ClearData()
     1143    HAPBook = G2G.GSNoteBook(parent=G2frame.dataWindow)
     1144    G2frame.dataWindow.GetSizer().Add(HAPBook,1,wx.ALL|wx.EXPAND,1)
     1145    phaseList = []
     1146    phaseIds = []
     1147    DData = []
     1148    sub = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Phases')
     1149    item, cookie = G2frame.GPXtree.GetFirstChild(sub)
     1150    while item: # loop over phases
     1151        phaseName = G2frame.GPXtree.GetItemText(item)
     1152        phaseIds.append(item)
     1153        phaseList.append(phaseName)
     1154        item, cookie = G2frame.GPXtree.GetNextChild(sub, cookie)
     1155        HAPtab = wx.ScrolledWindow(HAPBook)
     1156        HAPBook.AddPage(HAPtab,phaseName)
     1157        DData.append(HAPtab)
     1158    HAPBook.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, OnPageChanged)
     1159    # set up "Select tab" menu contents
     1160    G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.DataMenu)
     1161    mid = G2frame.dataWindow.DataMenu.FindMenu('Select tab')
     1162    menu = G2frame.dataWindow.DataMenu.GetMenu(mid)
     1163    items = menu.GetMenuItems()
     1164    for item in items:
     1165         menu.Remove(item)
     1166    if len(phaseList) == 0: return
     1167    for i,page in enumerate(phaseList):
     1168        Id = wx.NewId()
     1169        if menu.FindItem(page) >= 0: continue # is tab already in menu?
     1170        menu.Append(Id,page,'')
     1171        TabSelectionIdDict[Id] = page
     1172        G2frame.Bind(wx.EVT_MENU, OnSelectPage, id=Id)
     1173    # display the last-selected phase or the 1st
     1174    try:
     1175        G2frame.HistPhaseLastSel
     1176    except:
     1177        G2frame.HistPhaseLastSel = phaseList[0]
     1178    if G2frame.HistPhaseLastSel in phaseList:
     1179        page = phaseList.index(G2frame.HistPhaseLastSel)
     1180    else:
     1181        page = 0
     1182    # TODO: commands in G2frame.dataWindow.DataMenu/"Edit Phase" need to be reimplemented
     1183    HAPBook.SetSelection(page)
     1184    FillDDataWindow(page)
     1185   
Note: See TracChangeset for help on using the changeset viewer.