Ignore:
Timestamp:
Sep 29, 2014 2:31:04 PM (9 years ago)
Author:
toby
Message:

logging refactored, and much cleaner\!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branch/logging/GSASII.py

    r1505 r1509  
    16321632        if nextvalue:
    16331633            log.LogOn()
    1634             setto = True
     1634            set2 = True
    16351635        else:
    16361636            log.LogOff()
    1637             setto = False
     1637            set2 = False
    16381638        for menuitem in self.MacroStatusList:
    1639             menuitem.Check(setto)
     1639            menuitem.Check(set2)
    16401640
    16411641    def _init_Macro(self):
     
    16561656            print 70*'='
    16571657            print 'List of logged actions'
    1658             for line in log.G2logList:
    1659                 if line: print line
     1658            for i,line in enumerate(log.G2logList):
     1659                if line: print i,line
    16601660            print 70*'='
    16611661        self.Bind(wx.EVT_MENU, OnShowLog, item)
    16621662
     1663        item = menu.Append(
     1664            help='Clear logged commands', id=wx.ID_ANY,
     1665            kind=wx.ITEM_NORMAL,text='Clear log')
     1666        def OnClearLog(event): log.G2logList=[None]
     1667        self.Bind(wx.EVT_MENU, OnClearLog, item)
     1668       
    16631669        item = menu.Append(
    16641670            help='Save logged commands to file', id=wx.ID_ANY,
     
    16861692            if filename:
    16871693                fp = open(filename,'wb')
    1688                 fp.write(str(len(log.G2logList))+'\n')
     1694                fp.write(str(len(log.G2logList)-1)+'\n')
    16891695                for item in log.G2logList:
    1690                     cPickle.dump(item,fp)
     1696                    if item: cPickle.dump(item,fp)
    16911697                fp.close()
    16921698        self.Bind(wx.EVT_MENU, OnSaveLog, item)
     
    16961702            kind=wx.ITEM_NORMAL,text='Load log')
    16971703        def OnLoadLog(event):
     1704            # this appends. Perhaps we should ask to clear?
    16981705            import log
    16991706            import cPickle
     
    19741981        #self.PatternTree = wx.TreeCtrl(id=wxID_PATTERNTREE,
    19751982        import log
    1976         self.PatternTree = log.G2TreeCtrl(id=wxID_PATTERNTREE,
     1983        self.PatternTree = G2gd.G2TreeCtrl(id=wxID_PATTERNTREE,
    19771984            parent=self.mainPanel, pos=wx.Point(0, 0),style=wx.TR_DEFAULT_STYLE )
    19781985        self.PatternTree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnPatternTreeSelChanged)
Note: See TracChangeset for help on using the changeset viewer.