Ignore:
Timestamp:
Jul 6, 2017 3:09:41 PM (4 years ago)
Author:
toby
Message:

implement restraint tab selection menu; fix restraint scroll bar problem (remove/comment all DestroyChildren?); consolidate menu generation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branch/2frame/GSASIIdataGUI.py

    r2911 r2913  
    29182918        self.ExportCIF = []
    29192919        #
    2920         self.GSASIIMenu = wx.MenuBar()
    2921         # create a list of all menus (appended in PrefillDataMenu)
    2922         self.dataMenuBars = [self.GSASIIMenu]
    2923         self.MacroStatusList = []
    2924         self.FillMainMenu(self.GSASIIMenu)
    2925         self.SetMenuBar(self.GSASIIMenu)
     2920        # Main menu now done in DataWindow._initMenus for consistency
     2921        #self.GSASIIMenu = wx.MenuBar()
     2922        #self.dataMenuBars = [self.GSASIIMenu] # list of all menus (added to in PrefillDataMenu)
     2923        #self.FillMainMenu(self.GSASIIMenu)
     2924        #self.SetMenuBar(self.GSASIIMenu)
     2925        self.MacroStatusList = []  # logging
    29262926        self.Status = self.CreateStatusBar()
    29272927        # Bob: note different ways to display the SplitterWindow. I like the 3d effect on the Mac
     
    29652965        self.root = self.GPXtree.root       
    29662966
    2967         # debug code to fill initial window and check scroll bar works
    2968         #def FillWindow(panel,size=1.):
    2969         #    sizer = panel.GetSizer()
    2970         #    sizer.Add(wx.StaticText(panel, wx.ID_ANY, "Panel Two: long line "+int(size*40)*'*', (5,5)))
    2971         #    for i in range(int(size*15)): sizer.Add(wx.StaticText(panel, wx.ID_ANY, "Line "+str(2+i), (5,5)))
    2972         #    panel.Layout()
    2973         #    panel.SendSizeEvent()
    2974         #FillWindow(self.dataWindow)
    2975        
    29762967        self.dataWindow.SetupScrolling()
    29772968       
     
    47424733    where the functions to be called are defined.
    47434734    '''
     4735    # TODO: debug code ######################################################################
    47444736    def Bind(self,eventtype,handler,*args,**kwargs):  # PATCH: debug code: catch when a menu is bind'ed to
    4745         # the dataWindow this should not be done in the 2 frame version. Remove this routine eventually.
     4737        # the dataWindow as this should not be done in the 2 frame version.
    47464738        if eventtype == wx.wx.EVT_MENU:
    47474739            print 'wx.EVT_MENU Bind to dataWindow'
     
    47504742        else:
    47514743            wxscroll.ScrolledPanel.Bind(self,eventtype,handler,*args,**kwargs)
    4752 #    def Bind(self,eventtype,handler,*args,**kwargs):
    4753 #        '''Override the Bind() function: on the Mac the binding is to
    4754 #        the main window, so that menus operate with any window on top.
    4755 #        For other platforms, either wrap calls that will be logged
    4756 #        or call the default wx.Frame Bind() to bind to the menu item directly.
    4757 #
    4758 #        Note that bindings can be made to objects by Id or by direct reference to the
    4759 #        object. As a convention, when bindings are to objects, they are not logged
    4760 #        but when bindings are by Id, they are logged.
    4761 #        '''
    4762 #        if sys.platform == "darwin": # mac
    4763 #            self.Bind(eventtype,handler,*args,**kwargs)
    4764 #            return
    4765 #        if eventtype == wx.EVT_MENU and 'id' in kwargs:
    4766 ##            menulabels = log.SaveMenuCommand(kwargs['id'],self,handler)
    4767 ##            if menulabels:
    4768 ##                #print 'intercepting bind for',handler,menulabels,kwargs['id']
    4769 ##                wx.Window.Bind(self,eventtype,self.MenuBinding,*args,**kwargs)
    4770 ##                return
    4771 #            self.Bind(self,eventtype,handler,*args,**kwargs)
    4772 
    47734744    def DestroyChildren(self):
    4774         print 'Fix this: DestroyChildren called'
     4745        print 'Fix this: dataWindow.DestroyChildren called'
    47754746        G2obj.HowDidIgetHere()
    4776        
     4747    def SetTitle(self,*args):
     4748        print('Warning: attempt to label dataWindow')
     4749        G2obj.HowDidIgetHere(True)
     4750        self.G2frame.SetTitle(*args)
     4751    def SetLabel(self,*args):
     4752        print('Warning: attempt to label dataWindow')
     4753        G2obj.HowDidIgetHere(True)
     4754        self.G2frame.SetTitle(*args)
     4755    # end TODO: remove this later ############################################################
     4756
     4757    def __init__(self,parent):
     4758        wxscroll.ScrolledPanel.__init__(self,parent,wx.ID_ANY,size=parent.GetSize())
     4759        self.parent = parent
     4760        self._initMenus()
     4761        self.currentGrids = []
     4762        self.helpKey = ''  # defines help entry for current item selected in data tree
     4763       
     4764    def ClearData(self):
     4765        '''Initializes the contents of the dataWindow panel
     4766        '''
     4767        #self.SetBackgroundColour(wx.WHITE)
     4768        self.SetBackgroundColour(VERY_LIGHT_GREY)  # BHT: I prefer a gray background. Makes TextCtrls stand out, but
     4769        # a bit lighter than the splitter bar
     4770        Sizer = self.GetSizer()
     4771        if Sizer:
     4772            Sizer.Clear(True)
     4773        else:
     4774            print 'No sizer in dataWindow'
     4775            if GSASIIpath.GetConfigValue('debug'): raise Exception
     4776       
     4777    def SetDataSize(self):
     4778        '''Sizes the contents of the dataWindow panel
     4779        '''
     4780        Sizer = self.GetSizer()
     4781        if GSASIIpath.GetConfigValue('debug') and not Sizer:
     4782            print 'No sizer in dataWindow'
     4783            raise Exception
     4784        self.Layout()
     4785        self.SendSizeEvent()
     4786
    47774787    def PrefillDataMenu(self,menu,empty=False):
    47784788        '''Create the "standard" part of data frame menus & add the dataWindow menu headings
     
    47964806        menu.Append(menu=HelpMenu,title='&Help')
    47974807
    4798     def _initMenus_(self):
     4808    def _initMenus(self):
    47994809        'define all GSAS-II data window menus'
    4800 
    4801         # for use where no menu or data frame help is provided
    4802         self.BlankMenu = wx.MenuBar()
    4803        
     4810       
     4811        # Main menu
     4812        G2frame = self.GetTopLevelParent()
     4813        G2frame.GSASIIMenu = wx.MenuBar()
     4814        G2frame.dataMenuBars = [G2frame.GSASIIMenu] # list of all menus (added to in PrefillDataMenu)
     4815        G2frame.FillMainMenu(G2frame.GSASIIMenu)
     4816        G2frame.SetMenuBar(G2frame.GSASIIMenu)
     4817
    48044818        # Controls
    48054819        self.ControlsMenu = wx.MenuBar()
     
    51005114        self.InstEdit.Append(id=wxID_INST1VAL, kind=wx.ITEM_NORMAL,text='Set one value',
    51015115            help='Set one instrument parameter value across multiple histograms')
    5102 
    51035116        self.PostfillDataMenu()
    51045117       
     
    57325745    # end of GSAS-II menu definitions
    57335746   
    5734     def __init__(self,parent):
    5735         wxscroll.ScrolledPanel.__init__(self,parent,wx.ID_ANY,size=parent.GetSize())
    5736         self.parent = parent
    5737         self._initMenus_()
    5738         self.currentGrids = []
    5739         self.helpKey = ''  # defines help entry for current item selected in data tree
    5740        
    5741     def ClearData(self):
    5742         '''Initializes the contents of the dataWindow panel
    5743         '''
    5744         #self.SetBackgroundColour(wx.WHITE)  # BHT: I prefer a gray background. Makes TextCtrls stand out
    5745         self.SetBackgroundColour(VERY_LIGHT_GREY)  # BHT: I prefer a gray background. Makes TextCtrls stand out, but
    5746         # a bit lighter than the splitter bar
    5747 
    5748         Sizer = self.GetSizer()
    5749         if Sizer:
    5750             Sizer.Clear(True)
    5751         else:
    5752             print 'No sizer in dataWindow'
    5753             if GSASIIpath.GetConfigValue('debug'): raise Exception
    5754        
    5755     def SetDataSize(self):
    5756         '''Sizes the contents of the dataWindow panel
    5757         '''
    5758         Sizer = self.GetSizer()
    5759         if GSASIIpath.GetConfigValue('debug') and not Sizer:
    5760             print 'No sizer in dataWindow'
    5761             raise Exception
    5762         self.Layout()
    5763         self.SendSizeEvent()
    5764 
    5765     # TODO: remove this later
    5766     def SetTitle(self,*args):
    5767         print('Warning: attempt to label dataWindow')
    5768         G2obj.HowDidIgetHere()
    5769         self.G2frame.SetTitle(*args)
    5770     def SetTitle(self,*args):
    5771         print('Warning: attempt to label dataWindow')
    5772         G2obj.HowDidIgetHere()
    5773         self.G2frame.SetTitle(*args)
    5774 
    57755747       
    57765748#TODO - remove         
     
    77427714        if G2frame.dataDisplay:
    77437715            oldPage = G2frame.dataDisplay.GetSelection()
    7744     #G2frame.SetLabel(G2frame.GetLabel().split('||')[0]+' || '+'')
    77457716    G2frame.SetLabel('')
    77467717       
Note: See TracChangeset for help on using the changeset viewer.