Changeset 1538


Ignore:
Timestamp:
Oct 26, 2014 5:30:49 AM (7 years ago)
Author:
toby
Message:

simplify Select tab for phases to look up text from menu item; old code did not work on Mac consistently

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r1530 r1538  
    54565456
    54575457    def FillSelectPageMenu(menuBar):
    5458         '''Assign bindings to the menu buttons to switch between phase tabs;
    5459         define a dictionary with the page index for each tab
     5458        '''Fill "Select tab" menu with menu items for each tab and assign
     5459        bindings to the menu ietm to switch between phase tabs
    54605460        '''
    54615461        def OnSelectPage(event):
    54625462            'Called when an item is selected from the Select page menu'
    5463             page = Pagedict.get(event.GetId())
    5464             if page is not None: G2frame.dataDisplay.SetSelection(page)
     5463            # lookup the menu item that called us and get its text
     5464            mid = menuBar.FindMenu('Select tab')
     5465            menu = menuBar.GetMenu(mid)
     5466            tabname = menu.FindItemById(event.GetId()).Label
     5467            # find the matching tab
     5468            for PageNum in range(G2frame.dataDisplay.GetPageCount()):
     5469                if tabname == G2frame.dataDisplay.GetPageText(PageNum):
     5470                    G2frame.dataDisplay.SetSelection(PageNum)
     5471                    return
     5472            else:
     5473                print "Warning: tab "+tabname+" was not found"
    54655474        mid = menuBar.FindMenu('Select tab')
    5466         Pagedict = {}
    54675475        for ipage,page in enumerate(Pages):
    54685476            menu = menuBar.GetMenu(mid)
     
    54715479                menu.Append(id=Id,kind=wx.ITEM_NORMAL,text=page)
    54725480                G2frame.Bind(wx.EVT_MENU, OnSelectPage, id=Id)
    5473                 Pagedict[Id] = ipage
    5474 
    54755481       
    54765482    def OnPageChanged(event):
Note: See TracChangeset for help on using the changeset viewer.