Changeset 1477
- Timestamp:
- Aug 24, 2014 8:57:46 PM (9 years ago)
- Location:
- branch/logging
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/logging/GSASII.py
r1453 r1477 1845 1845 1846 1846 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, 1848 1850 parent=self.mainPanel, pos=wx.Point(0, 0),style=wx.TR_DEFAULT_STYLE ) 1849 1851 self.PatternTree.Bind(wx.EVT_TREE_SEL_CHANGED, … … 1857 1859 self.PatternTree.Bind(wx.EVT_TREE_KEY_DOWN, 1858 1860 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 1860 1863 1861 1864 plotFrame = wx.Frame(None,-1,'GSASII Plots',size=wx.Size(700,600), \ -
branch/logging/GSASIIgrid.py
r1445 r1477 45 45 import GSASIIobj as G2obj 46 46 import GSASIIexprGUI as G2exG 47 import log 47 48 48 49 # trig functions in degrees … … 155 156 ################################################################################ 156 157 #### GSAS-II class definitions 157 ################################################################################ 158 158 ################################################################################ 159 159 160 class ValidatedTxtCtrl(wx.TextCtrl): 160 161 '''Create a TextCtrl widget that uses a validator to prevent the … … 321 322 if self.result is not None: # note that this bypasses formatting 322 323 self.result[self.key] = val 324 log.LogVarChange(self.result,self.key) 323 325 self._setValue(val) 324 326 … … 410 412 else: 411 413 self.result[self.key] = val 414 log.LogVarChange(self.result,self.key) 412 415 413 416 def _GetStringValue(self,event): … … 424 427 else: 425 428 self.result[self.key] = val 429 log.LogVarChange(self.result,self.key) 426 430 427 431 def _onLoseFocus(self,event): … … 540 544 if val == '?' or val == '.': 541 545 self.result[self.key] = val 546 log.LogVarChange(self.result,self.key) 542 547 return 543 548 try: … … 568 573 if self.key is not None and self.result is not None and not tc.invalid: 569 574 self.result[self.key] = val 575 log.LogVarChange(self.result,self.key) 570 576 571 577 def ShowValidity(self,tc): … … 683 689 ''' 684 690 self.result[self.key] = tc.GetValue().encode('ascii','replace') 691 log.LogVarChange(self.result,self.key) 685 692 686 693 def OnChar(self, event): … … 788 795 def _OnCheckBox(self,event): 789 796 self.loc[self.key] = self.GetValue() 797 log.LogVarChange(self.loc,self.key) 790 798 ################################################################################ 791 799 class G2ChoiceButton(wx.Choice): … … 793 801 the control to match a supplied value and saves the choice directly 794 802 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. 796 807 797 808 :param wx.Panel parent: name of panel or frame that will be … … 799 810 :param list choiceList: a list or tuple of choices to offer the user. 800 811 :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. 802 813 :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. 807 819 :param dict/list strLoc: a dict or list with the string value corresponding to 808 820 indLoc/indKey. Default (None) means that this is not used. 809 821 :param int/str strKey: the dict key or the list index for the string value 810 822 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. 812 824 ''' 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, 814 826 onChoice=None,**kwargs): 815 827 wx.Choice.__init__(self,parent,choices=choiceList,id=wx.ID_ANY,**kwargs) … … 820 832 self.strKey = strKey 821 833 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: 823 836 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 826 848 self.Bind(wx.EVT_CHOICE, self._OnChoice) 827 if self.strLoc is not None: # make sure strLoc gets initialized828 self._OnChoice(None) # note that onChoice will not be called849 #if self.strLoc is not None: # make sure strLoc gets initialized 850 # self._OnChoice(None) # note that onChoice will not be called 829 851 self.onChoice = onChoice 830 852 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) 832 856 if self.strLoc is not None: 833 857 self.strLoc[self.strKey] = self.GetStringSelection() 858 log.LogVarChange(self.strLoc,self.strKey) 834 859 if self.onChoice: 835 860 self.onChoice() … … 3905 3930 mainSizer.Add(AuthSizer()) 3906 3931 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 3908 3946 mainSizer.Layout() 3909 3947 G2frame.dataDisplay.SetSizer(mainSizer) … … 5412 5450 for i in traceback.format_list(traceback.extract_stack()[:-1]): print(i.strip.rstrip()) 5413 5451 print 70*'*' 5414 5452 5415 5453 if __name__ == '__main__': 5416 5454 app = wx.PySimpleApp() -
branch/logging/GSASIIphsGUI.py
r1453 r1477 5261 5261 5262 5262 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) 5265 5266 text = G2frame.dataDisplay.GetPageText(page) 5266 5267 # print 'Select',page,text -
branch/logging/GSASIIpwdGUI.py
r1453 r1477 1600 1600 dlg.Destroy() 1601 1601 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 ''' 1608 1605 wx.CallAfter(UpdateSampleGrid,G2frame,data) 1609 1606 … … 1695 1692 if 'SlitLen' not in data and 'SASD' in histName: 1696 1693 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] 1697 1698 data['InstrName'] = data.get('InstrName','') 1698 1699 #patch end … … 1725 1726 0,WACV) 1726 1727 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) 1730 1731 nameSizer.Add(histoType) 1731 1732 mainSizer.Add(nameSizer,0,wx.EXPAND,1)
Note: See TracChangeset
for help on using the changeset viewer.