Changeset 1477 for branch/logging


Ignore:
Timestamp:
Aug 24, 2014 8:57:46 PM (9 years ago)
Author:
toby
Message:

variable change logging finally works

Location:
branch/logging
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branch/logging/GSASII.py

    r1453 r1477  
    18451845       
    18461846        wxID_PATTERNTREE = wx.NewId()
    1847         self.PatternTree = wx.TreeCtrl(id=wxID_PATTERNTREE,
     1847        #self.PatternTree = wx.TreeCtrl(id=wxID_PATTERNTREE,
     1848        import log
     1849        self.PatternTree = log.G2TreeCtrl(id=wxID_PATTERNTREE,
    18481850            parent=self.mainPanel, pos=wx.Point(0, 0),style=wx.TR_DEFAULT_STYLE )
    18491851        self.PatternTree.Bind(wx.EVT_TREE_SEL_CHANGED,
     
    18571859        self.PatternTree.Bind(wx.EVT_TREE_KEY_DOWN,
    18581860            self.OnPatternTreeKeyDown, id=wxID_PATTERNTREE)
    1859         self.root = self.PatternTree.AddRoot('Loaded Data: ')
     1861        #self.root = self.PatternTree.AddRoot('Loaded Data: ')
     1862        self.root = self.PatternTree.root
    18601863       
    18611864        plotFrame = wx.Frame(None,-1,'GSASII Plots',size=wx.Size(700,600), \
  • branch/logging/GSASIIgrid.py

    r1445 r1477  
    4545import GSASIIobj as G2obj
    4646import GSASIIexprGUI as G2exG
     47import log
    4748
    4849# trig functions in degrees
     
    155156################################################################################
    156157#### GSAS-II class definitions
    157 ################################################################################
    158        
     158################################################################################       
     159
    159160class ValidatedTxtCtrl(wx.TextCtrl):
    160161    '''Create a TextCtrl widget that uses a validator to prevent the
     
    321322        if self.result is not None: # note that this bypasses formatting
    322323            self.result[self.key] = val
     324            log.LogVarChange(self.result,self.key)
    323325        self._setValue(val)
    324326
     
    410412        else:
    411413            self.result[self.key] = val
     414        log.LogVarChange(self.result,self.key)
    412415
    413416    def _GetStringValue(self,event):
     
    424427        else:
    425428            self.result[self.key] = val
     429        log.LogVarChange(self.result,self.key)
    426430
    427431    def _onLoseFocus(self,event):
     
    540544            if val == '?' or val == '.':
    541545                self.result[self.key] = val
     546                log.LogVarChange(self.result,self.key)
    542547                return
    543548        try:
     
    568573        if self.key is not None and self.result is not None and not tc.invalid:
    569574            self.result[self.key] = val
     575            log.LogVarChange(self.result,self.key)
    570576
    571577    def ShowValidity(self,tc):
     
    683689        '''
    684690        self.result[self.key] = tc.GetValue().encode('ascii','replace')
     691        log.LogVarChange(self.result,self.key)
    685692
    686693    def OnChar(self, event):
     
    788795    def _OnCheckBox(self,event):
    789796        self.loc[self.key] = self.GetValue()
     797        log.LogVarChange(self.loc,self.key)
    790798################################################################################
    791799class G2ChoiceButton(wx.Choice):
     
    793801    the control to match a supplied value and saves the choice directly
    794802    into an array or list. Optionally a function can be called each time a
    795     choice is selected.
     803    choice is selected. The widget can be used with an array item that is set to
     804    to the choice by number (``indLoc[indKey]``) or by string value
     805    (``strLoc[strKey]``) or both. The initial value is taken from ``indLoc[indKey]``
     806    if not None or ``strLoc[strKey]`` if not None.
    796807
    797808    :param wx.Panel parent: name of panel or frame that will be
     
    799810    :param list choiceList: a list or tuple of choices to offer the user.
    800811    :param dict/list indLoc: a dict or list with the initial value to be
    801       placed in the Choice button.
     812      placed in the Choice button. If this is None, this is ignored.
    802813    :param int/str indKey: the dict key or the list index for the value to be
    803       edited by the Choice button. The ``indLoc[indKey]`` element must exist.
    804       The value for this should be None or an integer in range(len(choiceList)).
    805       The Choice button will be initialized to the choice corresponding to the
    806       value in this element if not None.
     814      edited by the Choice button. If indLoc is not None then this
     815      must be specified and the ``indLoc[indKey]`` will be set. If the value
     816      for ``indLoc[indKey]`` is not None, it should be an integer in
     817      range(len(choiceList)). The Choice button will be initialized to the
     818      choice corresponding to the value in this element if not None.
    807819    :param dict/list strLoc: a dict or list with the string value corresponding to
    808820      indLoc/indKey. Default (None) means that this is not used.
    809821    :param int/str strKey: the dict key or the list index for the string value
    810822      The ``strLoc[strKey]`` element must exist or strLoc must be None (default).
    811     :param function onChoice: name of a  
     823    :param function onChoice: name of a function to call when the choice is made.
    812824    '''
    813     def __init__(self,parent,choiceList,indLoc,indKey,strLoc=None,strKey=None,
     825    def __init__(self,parent,choiceList,indLoc=None,indKey=None,strLoc=None,strKey=None,
    814826                 onChoice=None,**kwargs):
    815827        wx.Choice.__init__(self,parent,choices=choiceList,id=wx.ID_ANY,**kwargs)
     
    820832        self.strKey = strKey
    821833        self.onChoice = None
    822         if self.indLoc[self.indKey] is not None:
     834        self.SetSelection(wx.NOT_FOUND)
     835        if self.indLoc is not None and self.indLoc.get(self.indKey) is not None:
    823836            self.SetSelection(self.indLoc[self.indKey])
    824         else:
    825             self.SetSelection(wx.NOT_FOUND)
     837            if self.strLoc is not None:
     838                self.strLoc[self.strKey] = self.GetStringSelection()
     839                log.LogVarChange(self.strLoc,self.strKey)
     840        elif self.strLoc is not None and self.strLoc.get(self.strKey) is not None:
     841            try:
     842                self.SetSelection(choiceList.index(self.strLoc[self.strKey]))
     843                if self.indLoc is not None:
     844                    self.indLoc[self.indKey] = self.GetSelection()
     845                    log.LogVarChange(self.indLoc,self.indKey)
     846            except ValueError:
     847                pass
    826848        self.Bind(wx.EVT_CHOICE, self._OnChoice)
    827         if self.strLoc is not None: # make sure strLoc gets initialized
    828             self._OnChoice(None) # note that onChoice will not be called
     849        #if self.strLoc is not None: # make sure strLoc gets initialized
     850        #    self._OnChoice(None) # note that onChoice will not be called
    829851        self.onChoice = onChoice
    830852    def _OnChoice(self,event):
    831         self.indLoc[self.indKey] = self.GetSelection()
     853        if self.indLoc is not None:
     854            self.indLoc[self.indKey] = self.GetSelection()
     855            log.LogVarChange(self.indLoc,self.indKey)
    832856        if self.strLoc is not None:
    833857            self.strLoc[self.strKey] = self.GetStringSelection()
     858            log.LogVarChange(self.strLoc,self.strKey)
    834859        if self.onChoice:
    835860            self.onChoice()
     
    39053930    mainSizer.Add(AuthSizer())
    39063931    mainSizer.Add((5,5),0)
    3907        
     3932
     3933    # DEBUG code: stick testing button on Controls page
     3934    import log
     3935    def TestButton(event):
     3936        print 'TestButton'
     3937        print event
     3938        treekeylist = [u'Phases', u'CuCr2O4']
     3939        log.SimTreeEvent(treekeylist)
     3940        log.SimTabPress('Phase Data for CuCr2O4','Atoms')
     3941    btn = wx.Button(G2frame.dataDisplay, wx.ID_ANY,"test")
     3942    btn.Bind(wx.EVT_BUTTON, TestButton)
     3943    mainSizer.Add(btn,0,wx.ALL,10)
     3944   
     3945           
    39083946    mainSizer.Layout()   
    39093947    G2frame.dataDisplay.SetSizer(mainSizer)
     
    54125450    for i in traceback.format_list(traceback.extract_stack()[:-1]): print(i.strip.rstrip())
    54135451    print 70*'*'   
    5414        
     5452           
    54155453if __name__ == '__main__':
    54165454    app = wx.PySimpleApp()
  • branch/logging/GSASIIphsGUI.py

    r1453 r1477  
    52615261       
    52625262    def ChangePage(page):
    5263         # development: Log Tab Selection
    5264         #G2gd.LogTabPress(G2frame,page)
     5263        # in development: Log Tab Selection
     5264        import log
     5265        log.LogTabPress(G2frame,page)
    52655266        text = G2frame.dataDisplay.GetPageText(page)
    52665267#        print 'Select',page,text
  • branch/logging/GSASIIpwdGUI.py

    r1453 r1477  
    16001600            dlg.Destroy()
    16011601
    1602     def OnHistoType(event):
    1603         Obj = event.GetEventObject()
    1604         data['Type'] = Obj.GetValue()
    1605         if data['Type'] == 'Bragg-Brentano' and 'Shift' not in data:    #set up defaults for new type(s)
    1606             data['Shift'] = [0.0,False]
    1607             data['Transparency'] = [0.0,False]
     1602    def OnHistoChange():
     1603        '''Called when the histogram type is changed to refresh the window
     1604        '''
    16081605        wx.CallAfter(UpdateSampleGrid,G2frame,data)
    16091606       
     
    16951692    if 'SlitLen' not in data and 'SASD' in histName:
    16961693        data['SlitLen'] = 0.0
     1694    if 'Shift' not in data:
     1695        data['Shift'] = [0.0,False]
     1696    if 'Transparency' not in data:
     1697        data['Transparency'] = [0.0,False]
    16971698    data['InstrName'] = data.get('InstrName','')
    16981699#patch end
     
    17251726                    0,WACV)
    17261727        choices = ['Debye-Scherrer','Bragg-Brentano',]
    1727         histoType = wx.ComboBox(G2frame.dataDisplay,wx.ID_ANY,value=data['Type'],choices=choices,
    1728             style=wx.CB_READONLY|wx.CB_DROPDOWN)
    1729         histoType.Bind(wx.EVT_COMBOBOX, OnHistoType)
     1728        histoType = G2gd.G2ChoiceButton(G2frame.dataDisplay,choices,
     1729                    strLoc=data,strKey='Type',
     1730                    onChoice=OnHistoChange)
    17301731        nameSizer.Add(histoType)
    17311732        mainSizer.Add(nameSizer,0,wx.EXPAND,1)
Note: See TracChangeset for help on using the changeset viewer.