Changeset 1831
- Timestamp:
- May 1, 2015 6:38:23 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1829 r1831 644 644 notOK = True 645 645 while notOK: 646 result = G2 gd.ItemSelector(TextList,self,header,header='Add histogram(s)',multiple=True)646 result = G2G.ItemSelector(TextList,self,header,header='Add histogram(s)',multiple=True) 647 647 if not result: return 648 648 # check that selected single crystal histograms are not already in use! … … 804 804 for Name in newHistList: 805 805 header += '\n '+str(Name) 806 result = G2 gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True)806 result = G2G.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True) 807 807 if not result: return 808 808 # connect new phases to histograms … … 1404 1404 header += '\n '+str(Name) 1405 1405 1406 result = G2 gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True)1406 result = G2G.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True) 1407 1407 if not result: return 1408 1408 # connect new phases to histograms … … 1569 1569 if not phaseNameList: return # no phases yet, nothing to do 1570 1570 header = 'Select phase(s) to add the new\npowder simulation (dummy) dataset to:' 1571 result = G2 gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True)1571 result = G2G.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True) 1572 1572 if not result: return 1573 1573 # connect new phases to histograms -
trunk/GSASIIIO.py
r1814 r1831 1925 1925 elif self.multiple: 1926 1926 choices = sorted(self.Phases.keys()) 1927 phasenum = G2 gd.ItemSelector(choices,self.G2frame,multiple=True)1927 phasenum = G2G.ItemSelector(choices,self.G2frame,multiple=True) 1928 1928 if phasenum is None: return True 1929 1929 self.phasenam = [choices[i] for i in phasenum] … … 1932 1932 else: 1933 1933 choices = sorted(self.Phases.keys()) 1934 phasenum = G2 gd.ItemSelector(choices,self.G2frame)1934 phasenum = G2G.ItemSelector(choices,self.G2frame) 1935 1935 if phasenum is None: return True 1936 1936 self.phasenam = [choices[phasenum]] … … 1946 1946 elif self.multiple: 1947 1947 choices = sorted(self.xtalDict.values()) 1948 hnum = G2 gd.ItemSelector(choices,self.G2frame,multiple=True)1948 hnum = G2G.ItemSelector(choices,self.G2frame,multiple=True) 1949 1949 if not hnum: return True 1950 1950 self.histnam = [choices[i] for i in hnum] … … 1952 1952 else: 1953 1953 choices = sorted(self.xtalDict.values()) 1954 hnum = G2 gd.ItemSelector(choices,self.G2frame)1954 hnum = G2G.ItemSelector(choices,self.G2frame) 1955 1955 if hnum is None: return True 1956 1956 self.histnam = [choices[hnum]] … … 1966 1966 elif self.multiple: 1967 1967 choices = sorted(self.powderDict.values()) 1968 hnum = G2 gd.ItemSelector(choices,self.G2frame,multiple=True)1968 hnum = G2G.ItemSelector(choices,self.G2frame,multiple=True) 1969 1969 if not hnum: return True 1970 1970 self.histnam = [choices[i] for i in hnum] … … 1972 1972 else: 1973 1973 choices = sorted(self.powderDict.values()) 1974 hnum = G2 gd.ItemSelector(choices,self.G2frame)1974 hnum = G2G.ItemSelector(choices,self.G2frame) 1975 1975 if hnum is None: return True 1976 1976 self.histnam = [choices[hnum]] … … 1986 1986 else: 1987 1987 choices = sorted(self.Histograms.keys()) 1988 hnum = G2 gd.ItemSelector(choices,self.G2frame,multiple=self.multiple)1988 hnum = G2G.ItemSelector(choices,self.G2frame,multiple=self.multiple) 1989 1989 if self.multiple: 1990 1990 if not hnum: return True … … 2019 2019 self.phasenam = mapPhases 2020 2020 else: 2021 phasenum = G2 gd.ItemSelector(choices,self.G2frame,multiple=self.multiple)2021 phasenum = G2G.ItemSelector(choices,self.G2frame,multiple=self.multiple) 2022 2022 if self.multiple: 2023 2023 if not phasenum: return True -
trunk/GSASIIconstrGUI.py
r1827 r1831 998 998 G2frame.dataFrame.Bind(wx.EVT_MENU, RaisePage,id=id) 999 999 1000 G2frame.dataDisplay = G2 gd.GSNoteBook(parent=G2frame.dataFrame)1000 G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame) 1001 1001 # note that order of pages is hard-coded in RaisePage 1002 1002 PhaseConstr = wx.ScrolledWindow(G2frame.dataDisplay) … … 1470 1470 table.append(list(xyz)+[rbData['rbTypes'][ivec],]+list(XYZ[ivec])) 1471 1471 rowLabels.append(str(ivec)) 1472 vecTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1473 vecGrid = G2 gd.GSGrid(VectorRBDisplay)1472 vecTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1473 vecGrid = G2G.GSGrid(VectorRBDisplay) 1474 1474 vecGrid.SetTable(vecTable, True) 1475 1475 vecGrid.Bind(wg.EVT_GRID_CELL_CHANGE, ChangeCell) … … 1477 1477 vecGrid.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, TypeSelect) 1478 1478 attr = wx.grid.GridCellAttr() 1479 attr.SetEditor(G2 gd.GridFractionEditor(vecGrid))1479 attr.SetEditor(G2G.GridFractionEditor(vecGrid)) 1480 1480 for c in range(3): 1481 1481 vecGrid.SetColAttr(c, attr) … … 1638 1638 table.append([rbData['atNames'][ivec],]+[rbData['rbTypes'][ivec],]+list(xyz)) 1639 1639 rowLabels.append(str(ivec)) 1640 vecTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1641 vecGrid = G2 gd.GSGrid(ResidueRBDisplay)1640 vecTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1641 vecGrid = G2G.GSGrid(ResidueRBDisplay) 1642 1642 Indx[vecGrid.GetId()] = rbId 1643 1643 resList.append(vecGrid) … … 1647 1647 vecGrid.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect) 1648 1648 attr = wx.grid.GridCellAttr() 1649 attr.SetEditor(G2 gd.GridFractionEditor(vecGrid))1649 attr.SetEditor(G2G.GridFractionEditor(vecGrid)) 1650 1650 for c in range(3): 1651 1651 vecGrid.SetColAttr(c, attr) … … 1826 1826 SetStatusLine('') 1827 1827 1828 G2frame.dataDisplay = G2 gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())1828 G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize()) 1829 1829 1830 1830 VectorRB = wx.ScrolledWindow(G2frame.dataDisplay) -
trunk/GSASIIctrls.py
r1814 r1831 18 18 ''' 19 19 import wx 20 #import wx.grid as wg20 import wx.grid as wg 21 21 # import wx.wizard as wz 22 #import wx.aui22 import wx.aui 23 23 import wx.lib.scrolledpanel as wxscroll 24 24 import time … … 766 766 767 767 ################################################################################ 768 #### Edit a large number of values 768 def HorizontalLine(sizer,parent): 769 '''Draws a horizontal line as wide as the window. 770 This shows up on the Mac as a very thin line, no matter what I do 771 ''' 772 line = wx.StaticLine(parent,-1, size=(-1,3), style=wx.LI_HORIZONTAL) 773 sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10) 774 775 ################################################################################ 776 class G2LoggedButton(wx.Button): 777 '''A version of wx.Button that creates logging events. Bindings are saved 778 in the object, and are looked up rather than directly set with a bind. 779 An index to these buttons is saved as log.ButtonBindingLookup 780 :param wx.Panel parent: parent widget 781 :param int id: Id for button 782 :param str label: label for button 783 :param str locationcode: a label used internally to uniquely indentify the button 784 :param function handler: a routine to call when the button is pressed 785 ''' 786 def __init__(self,parent,id=wx.ID_ANY,label='',locationcode='', 787 handler=None,*args,**kwargs): 788 super(self.__class__,self).__init__(parent,id,label,*args,**kwargs) 789 self.label = label 790 self.handler = handler 791 self.locationcode = locationcode 792 key = locationcode + '+' + label # hash code to find button 793 self.Bind(wx.EVT_BUTTON,self.onPress) 794 log.ButtonBindingLookup[key] = self 795 def onPress(self,event): 796 'create log event and call handler' 797 log.MakeButtonLog(self.locationcode,self.label) 798 self.handler(event) 799 800 ################################################################################ 801 class EnumSelector(wx.ComboBox): 802 '''A customized :class:`wxpython.ComboBox` that selects items from a list 803 of choices, but sets a dict (list) entry to the corresponding 804 entry from the input list of values. 805 806 :param wx.Panel parent: the parent to the :class:`~wxpython.ComboBox` (usually a 807 frame or panel) 808 :param dict dct: a dict (or list) to contain the value set 809 for the :class:`~wxpython.ComboBox`. 810 :param item: the dict key (or list index) where ``dct[item]`` will 811 be set to the value selected in the :class:`~wxpython.ComboBox`. Also, dct[item] 812 contains the starting value shown in the widget. If the value 813 does not match an entry in :data:`values`, the first value 814 in :data:`choices` is used as the default, but ``dct[item]`` is 815 not changed. 816 :param list choices: a list of choices to be displayed to the 817 user such as 818 :: 819 820 ["default","option 1","option 2",] 821 822 Note that these options will correspond to the entries in 823 :data:`values` (if specified) item by item. 824 :param list values: a list of values that correspond to 825 the options in :data:`choices`, such as 826 :: 827 828 [0,1,2] 829 830 The default for :data:`values` is to use the same list as 831 specified for :data:`choices`. 832 :param (other): additional keyword arguments accepted by 833 :class:`~wxpython.ComboBox` can be specified. 834 ''' 835 def __init__(self,parent,dct,item,choices,values=None,**kw): 836 if values is None: 837 values = choices 838 if dct[item] in values: 839 i = values.index(dct[item]) 840 else: 841 i = 0 842 startval = choices[i] 843 wx.ComboBox.__init__(self,parent,wx.ID_ANY,startval, 844 choices = choices, 845 style=wx.CB_DROPDOWN|wx.CB_READONLY, 846 **kw) 847 self.choices = choices 848 self.values = values 849 self.dct = dct 850 self.item = item 851 self.Bind(wx.EVT_COMBOBOX, self.onSelection) 852 def onSelection(self,event): 853 # respond to a selection by setting the enum value in the CIF dictionary 854 if self.GetValue() in self.choices: # should always be true! 855 self.dct[self.item] = self.values[self.choices.index(self.GetValue())] 856 else: 857 self.dct[self.item] = self.values[0] # unknown 858 859 ################################################################################ 860 class G2ChoiceButton(wx.Choice): 861 '''A customized version of a wx.Choice that automatically initializes 862 the control to match a supplied value and saves the choice directly 863 into an array or list. Optionally a function can be called each time a 864 choice is selected. The widget can be used with an array item that is set to 865 to the choice by number (``indLoc[indKey]``) or by string value 866 (``strLoc[strKey]``) or both. The initial value is taken from ``indLoc[indKey]`` 867 if not None or ``strLoc[strKey]`` if not None. 868 869 :param wx.Panel parent: name of panel or frame that will be 870 the parent to the widget. Can be None. 871 :param list choiceList: a list or tuple of choices to offer the user. 872 :param dict/list indLoc: a dict or list with the initial value to be 873 placed in the Choice button. If this is None, this is ignored. 874 :param int/str indKey: the dict key or the list index for the value to be 875 edited by the Choice button. If indLoc is not None then this 876 must be specified and the ``indLoc[indKey]`` will be set. If the value 877 for ``indLoc[indKey]`` is not None, it should be an integer in 878 range(len(choiceList)). The Choice button will be initialized to the 879 choice corresponding to the value in this element if not None. 880 :param dict/list strLoc: a dict or list with the string value corresponding to 881 indLoc/indKey. Default (None) means that this is not used. 882 :param int/str strKey: the dict key or the list index for the string value 883 The ``strLoc[strKey]`` element must exist or strLoc must be None (default). 884 :param function onChoice: name of a function to call when the choice is made. 885 ''' 886 def __init__(self,parent,choiceList,indLoc=None,indKey=None,strLoc=None,strKey=None, 887 onChoice=None,**kwargs): 888 wx.Choice.__init__(self,parent,choices=choiceList,id=wx.ID_ANY,**kwargs) 889 self.choiceList = choiceList 890 self.indLoc = indLoc 891 self.indKey = indKey 892 self.strLoc = strLoc 893 self.strKey = strKey 894 self.onChoice = None 895 self.SetSelection(wx.NOT_FOUND) 896 if self.indLoc is not None and self.indLoc.get(self.indKey) is not None: 897 self.SetSelection(self.indLoc[self.indKey]) 898 if self.strLoc is not None: 899 self.strLoc[self.strKey] = self.GetStringSelection() 900 log.LogVarChange(self.strLoc,self.strKey) 901 elif self.strLoc is not None and self.strLoc.get(self.strKey) is not None: 902 try: 903 self.SetSelection(choiceList.index(self.strLoc[self.strKey])) 904 if self.indLoc is not None: 905 self.indLoc[self.indKey] = self.GetSelection() 906 log.LogVarChange(self.indLoc,self.indKey) 907 except ValueError: 908 pass 909 self.Bind(wx.EVT_CHOICE, self._OnChoice) 910 #if self.strLoc is not None: # make sure strLoc gets initialized 911 # self._OnChoice(None) # note that onChoice will not be called 912 self.onChoice = onChoice 913 def _OnChoice(self,event): 914 if self.indLoc is not None: 915 self.indLoc[self.indKey] = self.GetSelection() 916 log.LogVarChange(self.indLoc,self.indKey) 917 if self.strLoc is not None: 918 self.strLoc[self.strKey] = self.GetStringSelection() 919 log.LogVarChange(self.strLoc,self.strKey) 920 if self.onChoice: 921 self.onChoice() 922 923 ############################################################### Custom checkbox that saves values into dict/list as used 924 class G2CheckBox(wx.CheckBox): 925 '''A customized version of a CheckBox that automatically initializes 926 the control to a supplied list or dict entry and updates that 927 entry as the widget is used. 928 929 :param wx.Panel parent: name of panel or frame that will be 930 the parent to the widget. Can be None. 931 :param str label: text to put on check button 932 :param dict/list loc: the dict or list with the initial value to be 933 placed in the CheckBox. 934 :param int/str key: the dict key or the list index for the value to be 935 edited by the CheckBox. The ``loc[key]`` element must exist. 936 The CheckBox will be initialized from this value. 937 If the value is anything other that True (or 1), it will be taken as 938 False. 939 ''' 940 def __init__(self,parent,label,loc,key): 941 wx.CheckBox.__init__(self,parent,id=wx.ID_ANY,label=label) 942 self.loc = loc 943 self.key = key 944 self.SetValue(self.loc[self.key]==True) 945 self.Bind(wx.EVT_CHECKBOX, self._OnCheckBox) 946 def _OnCheckBox(self,event): 947 self.loc[self.key] = self.GetValue() 948 log.LogVarChange(self.loc,self.key) 949 950 ################################################################################ 951 #### Commonly used dialogs 769 952 ################################################################################ 770 953 def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[], … … 788 971 return False 789 972 973 ################################################################################ 790 974 class ScrolledMultiEditor(wx.Dialog): 791 975 '''Define a window for editing a potentially large number of dict- or … … 1011 1195 self.OKbtn.Disable() 1012 1196 1013 ################################################################################ 1014 #### Multichoice Dialog with set all, toggle & filter options 1015 ################################################################################ 1197 ############################################### Multichoice Dialog with set all, toggle & filter options 1016 1198 class G2MultiChoiceDialog(wx.Dialog): 1017 1199 '''A dialog similar to MultiChoiceDialog except that buttons are … … 1391 1573 dlg.Destroy() 1392 1574 1393 ################################################################################ 1394 #### Single choice Dialog with filter options 1395 ################################################################################ 1575 ################################################################ Single choice Dialog with filter options 1396 1576 class G2SingleChoiceDialog(wx.Dialog): 1397 1577 '''A dialog similar to wx.SingleChoiceDialog except that a filter can be … … 1508 1688 1509 1689 ################################################################################ 1510 #### Custom checkbox that saves values into dict/list as used 1511 ################################################################################ 1512 class G2CheckBox(wx.CheckBox): 1513 '''A customized version of a CheckBox that automatically initializes 1514 the control to a supplied list or dict entry and updates that 1515 entry as the widget is used. 1516 1517 :param wx.Panel parent: name of panel or frame that will be 1518 the parent to the widget. Can be None. 1519 :param str label: text to put on check button 1520 :param dict/list loc: the dict or list with the initial value to be 1521 placed in the CheckBox. 1522 :param int/str key: the dict key or the list index for the value to be 1523 edited by the CheckBox. The ``loc[key]`` element must exist. 1524 The CheckBox will be initialized from this value. 1525 If the value is anything other that True (or 1), it will be taken as 1526 False. 1690 def G2MessageBox(parent,msg,title='Error'): 1691 '''Simple code to display a error or warning message 1527 1692 ''' 1528 def __init__(self,parent,label,loc,key): 1529 wx.CheckBox.__init__(self,parent,id=wx.ID_ANY,label=label) 1530 self.loc = loc 1531 self.key = key 1532 self.SetValue(self.loc[self.key]==True) 1533 self.Bind(wx.EVT_CHECKBOX, self._OnCheckBox) 1534 def _OnCheckBox(self,event): 1535 self.loc[self.key] = self.GetValue() 1536 log.LogVarChange(self.loc,self.key) 1537 1538 ################################################################################ 1539 #### 1693 dlg = wx.MessageDialog(parent,StripIndents(msg), title, wx.OK) 1694 dlg.ShowModal() 1695 dlg.Destroy() 1696 1540 1697 ################################################################################ 1541 1698 class PickTwoDialog(wx.Dialog): … … 1606 1763 1607 1764 ################################################################################ 1608 #### Column-order selection 1765 class SingleFloatDialog(wx.Dialog): 1766 'Dialog to obtain a single float value from user' 1767 def __init__(self,parent,title,prompt,value,limits=[0.,1.],format='%.5g'): 1768 wx.Dialog.__init__(self,parent,-1,title, 1769 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1770 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 1771 self.limits = limits 1772 self.value = value 1773 self.prompt = prompt 1774 self.format = format 1775 self.Draw() 1776 1777 def Draw(self): 1778 1779 def OnValItem(event): 1780 try: 1781 val = float(valItem.GetValue()) 1782 if val < self.limits[0] or val > self.limits[1]: 1783 raise ValueError 1784 except ValueError: 1785 val = self.value 1786 self.value = val 1787 valItem.SetValue(self.format%(self.value)) 1788 1789 self.panel.Destroy() 1790 self.panel = wx.Panel(self) 1791 mainSizer = wx.BoxSizer(wx.VERTICAL) 1792 mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER) 1793 valItem = wx.TextCtrl(self.panel,-1,value=self.format%(self.value),style=wx.TE_PROCESS_ENTER) 1794 mainSizer.Add(valItem,0,wx.ALIGN_CENTER) 1795 valItem.Bind(wx.EVT_TEXT_ENTER,OnValItem) 1796 valItem.Bind(wx.EVT_KILL_FOCUS,OnValItem) 1797 OkBtn = wx.Button(self.panel,-1,"Ok") 1798 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 1799 CancelBtn = wx.Button(self.panel,-1,'Cancel') 1800 CancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) 1801 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 1802 btnSizer.Add((20,20),1) 1803 btnSizer.Add(OkBtn) 1804 btnSizer.Add(CancelBtn) 1805 btnSizer.Add((20,20),1) 1806 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 1807 self.panel.SetSizer(mainSizer) 1808 self.panel.Fit() 1809 self.Fit() 1810 1811 def GetValue(self): 1812 return self.value 1813 1814 def OnOk(self,event): 1815 parent = self.GetParent() 1816 parent.Raise() 1817 self.EndModal(wx.ID_OK) 1818 1819 def OnCancel(self,event): 1820 parent = self.GetParent() 1821 parent.Raise() 1822 self.EndModal(wx.ID_CANCEL) 1823 1609 1824 ################################################################################ 1610 1825 class SingleStringDialog(wx.Dialog): 1826 '''Dialog to obtain a single string value from user 1827 1828 :param wx.Frame parent: name of parent frame 1829 :param str title: title string for dialog 1830 :param str prompt: string to tell use what they are inputting 1831 :param str value: default input value, if any 1832 ''' 1833 def __init__(self,parent,title,prompt,value='',size=(200,-1)): 1834 wx.Dialog.__init__(self,parent,wx.ID_ANY,title, 1835 pos=wx.DefaultPosition, 1836 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 1837 self.value = value 1838 self.prompt = prompt 1839 self.CenterOnParent() 1840 self.panel = wx.Panel(self) 1841 mainSizer = wx.BoxSizer(wx.VERTICAL) 1842 mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER) 1843 self.valItem = wx.TextCtrl(self.panel,-1,value=self.value,size=size) 1844 mainSizer.Add(self.valItem,0,wx.ALIGN_CENTER) 1845 btnsizer = wx.StdDialogButtonSizer() 1846 OKbtn = wx.Button(self.panel, wx.ID_OK) 1847 OKbtn.SetDefault() 1848 btnsizer.AddButton(OKbtn) 1849 btn = wx.Button(self.panel, wx.ID_CANCEL) 1850 btnsizer.AddButton(btn) 1851 btnsizer.Realize() 1852 mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) 1853 self.panel.SetSizer(mainSizer) 1854 self.panel.Fit() 1855 self.Fit() 1856 1857 def Show(self): 1858 '''Use this method after creating the dialog to post it 1859 :returns: True if the user pressed OK; False if the User pressed Cancel 1860 ''' 1861 if self.ShowModal() == wx.ID_OK: 1862 self.value = self.valItem.GetValue() 1863 return True 1864 else: 1865 return False 1866 1867 def GetValue(self): 1868 '''Use this method to get the value entered by the user 1869 :returns: string entered by user 1870 ''' 1871 return self.value 1872 1873 ################################################################################ 1874 class MultiStringDialog(wx.Dialog): 1875 '''Dialog to obtain a multi string values from user 1876 1877 :param wx.Frame parent: name of parent frame 1878 :param str title: title string for dialog 1879 :param str prompts: strings to tell use what they are inputting 1880 :param str values: default input values, if any 1881 ''' 1882 def __init__(self,parent,title,prompts,values=[]): #,size=(200,-1)? 1883 1884 wx.Dialog.__init__(self,parent,wx.ID_ANY,title, 1885 pos=wx.DefaultPosition, 1886 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 1887 self.values = values 1888 self.prompts = prompts 1889 self.CenterOnParent() 1890 self.panel = wx.Panel(self) 1891 mainSizer = wx.BoxSizer(wx.VERTICAL) 1892 promptSizer = wx.FlexGridSizer(0,2,5,5) 1893 self.Indx = {} 1894 for prompt,value in zip(prompts,values): 1895 promptSizer.Add(wx.StaticText(self.panel,-1,prompt),0,WACV) 1896 valItem = wx.TextCtrl(self.panel,-1,value=value,style=wx.TE_PROCESS_ENTER) 1897 self.Indx[valItem.GetId()] = prompt 1898 valItem.Bind(wx.EVT_TEXT,self.newValue) 1899 promptSizer.Add(valItem,0,WACV) 1900 mainSizer.Add(promptSizer,0) 1901 btnsizer = wx.StdDialogButtonSizer() 1902 OKbtn = wx.Button(self.panel, wx.ID_OK) 1903 OKbtn.SetDefault() 1904 btnsizer.AddButton(OKbtn) 1905 btn = wx.Button(self.panel, wx.ID_CANCEL) 1906 btnsizer.AddButton(btn) 1907 btnsizer.Realize() 1908 mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) 1909 self.panel.SetSizer(mainSizer) 1910 self.panel.Fit() 1911 self.Fit() 1912 1913 def newValue(self,event): 1914 Obj = event.GetEventObject() 1915 item = self.Indx[Obj.GetId()] 1916 id = self.prompts.index(item) 1917 self.values[id] = Obj.GetValue() 1918 1919 def Show(self): 1920 '''Use this method after creating the dialog to post it 1921 :returns: True if the user pressed OK; False if the User pressed Cancel 1922 ''' 1923 if self.ShowModal() == wx.ID_OK: 1924 return True 1925 else: 1926 return False 1927 1928 def GetValues(self): 1929 '''Use this method to get the value entered by the user 1930 :returns: string entered by user 1931 ''' 1932 return self.values 1933 1934 ################################################################################ 1935 class G2ColumnIDDialog(wx.Dialog): 1936 '''A dialog for matching column data to desired items; some columns may be ignored. 1937 1938 :param wx.Frame ParentFrame: reference to parent frame 1939 :param str title: heading above list of choices 1940 :param str header: Title to place on window frame 1941 :param list ChoiceList: a list of possible choices for the columns 1942 :param list ColumnData: lists of column data to be matched with ChoiceList 1943 :param bool monoFont: If False (default), use a variable-spaced font; 1944 if True use a equally-spaced font. 1945 :param kw: optional keyword parameters for the wx.Dialog may 1946 be included such as size [which defaults to `(320,310)`] and 1947 style (which defaults to ``wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.CENTRE | wx.OK | wx.CANCEL``); 1948 note that ``wx.OK`` and ``wx.CANCEL`` controls 1949 the presence of the eponymous buttons in the dialog. 1950 :returns: the name of the created dialog 1951 1952 ''' 1953 1954 def __init__(self,parent, title, header,Comments,ChoiceList, ColumnData, 1955 monoFont=False, **kw): 1956 1957 def OnOk(sevent): 1958 OK = True 1959 selCols = [] 1960 for col in self.sel: 1961 item = col.GetValue() 1962 if item != ' ' and item in selCols: 1963 OK = False 1964 break 1965 else: 1966 selCols.append(item) 1967 parent = self.GetParent() 1968 if not OK: 1969 parent.ErrorDialog('Duplicate',item+' selected more than once') 1970 return 1971 parent.Raise() 1972 self.EndModal(wx.ID_OK) 1973 1974 def OnModify(event): 1975 Obj = event.GetEventObject() 1976 icol,colData = Indx[Obj.GetId()] 1977 modify = Obj.GetValue() 1978 if not modify: 1979 return 1980 print 'Modify column',icol,' by', modify 1981 for i,item in enumerate(self.ColumnData[icol]): 1982 self.ColumnData[icol][i] = str(eval(item+modify)) 1983 colData.SetValue('\n'.join(self.ColumnData[icol])) 1984 Obj.SetValue('') 1985 1986 # process keyword parameters, notably style 1987 options = {'size':(600,310), # default Frame keywords 1988 'style':wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE| wx.OK | wx.CANCEL, 1989 } 1990 options.update(kw) 1991 self.Comments = ''.join(Comments) 1992 self.ChoiceList = ChoiceList 1993 self.ColumnData = ColumnData 1994 nCol = len(ColumnData) 1995 if options['style'] & wx.OK: 1996 useOK = True 1997 options['style'] ^= wx.OK 1998 else: 1999 useOK = False 2000 if options['style'] & wx.CANCEL: 2001 useCANCEL = True 2002 options['style'] ^= wx.CANCEL 2003 else: 2004 useCANCEL = False 2005 # create the dialog frame 2006 wx.Dialog.__init__(self,parent,wx.ID_ANY,header,**options) 2007 panel = wxscroll.ScrolledPanel(self) 2008 # fill the dialog 2009 Sizer = wx.BoxSizer(wx.VERTICAL) 2010 Sizer.Add((-1,5)) 2011 Sizer.Add(wx.StaticText(panel,label=title),0,WACV) 2012 if self.Comments: 2013 Sizer.Add(wx.StaticText(panel,label=' Header lines:'),0,WACV) 2014 Sizer.Add(wx.TextCtrl(panel,value=self.Comments,size=(200,-1), 2015 style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP),0,wx.ALL|wx.EXPAND|WACV,8) 2016 columnsSizer = wx.FlexGridSizer(0,nCol,5,10) 2017 self.sel = [] 2018 self.mod = [] 2019 Indx = {} 2020 for icol,col in enumerate(self.ColumnData): 2021 colSizer = wx.BoxSizer(wx.VERTICAL) 2022 colSizer.Add(wx.StaticText(panel,label=' Column #%d Select:'%(icol)),0,WACV) 2023 self.sel.append(wx.ComboBox(panel,value=' ',choices=self.ChoiceList,style=wx.CB_READONLY|wx.CB_DROPDOWN)) 2024 colSizer.Add(self.sel[-1]) 2025 colData = wx.TextCtrl(panel,value='\n'.join(self.ColumnData[icol]),size=(120,-1), 2026 style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP) 2027 colSizer.Add(colData,0,WACV) 2028 colSizer.Add(wx.StaticText(panel,label=' Modify by:'),0,WACV) 2029 mod = wx.TextCtrl(panel,size=(120,-1),value='',style=wx.TE_PROCESS_ENTER) 2030 mod.Bind(wx.EVT_TEXT_ENTER,OnModify) 2031 mod.Bind(wx.EVT_KILL_FOCUS,OnModify) 2032 Indx[mod.GetId()] = [icol,colData] 2033 colSizer.Add(mod,0,WACV) 2034 columnsSizer.Add(colSizer) 2035 Sizer.Add(columnsSizer) 2036 Sizer.Add(wx.StaticText(panel,label=' For modify by, enter arithmetic string eg. "-12345.67". "+","-","*","/","**" all allowed'),0,WACV) 2037 Sizer.Add((-1,10)) 2038 # OK/Cancel buttons 2039 btnsizer = wx.StdDialogButtonSizer() 2040 if useOK: 2041 self.OKbtn = wx.Button(panel, wx.ID_OK) 2042 self.OKbtn.SetDefault() 2043 btnsizer.AddButton(self.OKbtn) 2044 self.OKbtn.Bind(wx.EVT_BUTTON, OnOk) 2045 if useCANCEL: 2046 btn = wx.Button(panel, wx.ID_CANCEL) 2047 btnsizer.AddButton(btn) 2048 btnsizer.Realize() 2049 Sizer.Add((-1,5)) 2050 Sizer.Add(btnsizer,0,wx.ALIGN_LEFT,20) 2051 Sizer.Add((-1,5)) 2052 # OK done, let's get outa here 2053 panel.SetSizer(Sizer) 2054 panel.SetAutoLayout(1) 2055 panel.SetupScrolling() 2056 Size = [450,375] 2057 panel.SetSize(Size) 2058 Size[0] += 25; Size[1]+= 25 2059 self.SetSize(Size) 2060 2061 def GetSelection(self): 2062 'Returns the selected sample parm for each column' 2063 selCols = [] 2064 for item in self.sel: 2065 selCols.append(item.GetValue()) 2066 return selCols,self.ColumnData 2067 2068 ################################################################################ 2069 def ItemSelector(ChoiceList, ParentFrame=None, 2070 title='Select an item', 2071 size=None, header='Item Selector', 2072 useCancel=True,multiple=False): 2073 ''' Provide a wx dialog to select a single item or multiple items from list of choices 2074 2075 :param list ChoiceList: a list of choices where one will be selected 2076 :param wx.Frame ParentFrame: Name of parent frame (default None) 2077 :param str title: heading above list of choices (default 'Select an item') 2078 :param wx.Size size: Size for dialog to be created (default None -- size as needed) 2079 :param str header: Title to place on window frame (default 'Item Selector') 2080 :param bool useCancel: If True (default) both the OK and Cancel buttons are offered 2081 :param bool multiple: If True then multiple items can be selected (default False) 2082 2083 :returns: the selection index or None or a selection list if multiple is true 2084 ''' 2085 if multiple: 2086 if useCancel: 2087 dlg = G2G.G2MultiChoiceDialog( 2088 ParentFrame,title, header, ChoiceList) 2089 else: 2090 dlg = G2G.G2MultiChoiceDialog( 2091 ParentFrame,title, header, ChoiceList, 2092 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 2093 else: 2094 if useCancel: 2095 dlg = wx.SingleChoiceDialog( 2096 ParentFrame,title, header, ChoiceList) 2097 else: 2098 dlg = wx.SingleChoiceDialog( 2099 ParentFrame,title, header,ChoiceList, 2100 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 2101 if size: dlg.SetSize(size) 2102 if dlg.ShowModal() == wx.ID_OK: 2103 if multiple: 2104 dlg.Destroy() 2105 return dlg.GetSelections() 2106 else: 2107 dlg.Destroy() 2108 return dlg.GetSelection() 2109 else: 2110 dlg.Destroy() 2111 return None 2112 dlg.Destroy() 2113 2114 ######################################################### Column-order selection dialog 1611 2115 def GetItemOrder(parent,keylist,vallookup,posdict): 1612 2116 '''Creates a panel where items can be ordered into columns … … 1749 2253 1750 2254 ################################################################################ 2255 ##### Customized Grid Support 2256 ################################################################################ 2257 class GSGrid(wg.Grid): 2258 '''Basic wx.Grid implementation 2259 ''' 2260 def __init__(self, parent, name=''): 2261 wg.Grid.__init__(self,parent,-1,name=name) 2262 #self.SetSize(parent.GetClientSize()) 2263 # above removed to speed drawing of initial grid 2264 # does not appear to be needed 2265 2266 def Clear(self): 2267 wg.Grid.ClearGrid(self) 2268 2269 def SetCellReadOnly(self,r,c,readonly=True): 2270 self.SetReadOnly(r,c,isReadOnly=readonly) 2271 2272 def SetCellStyle(self,r,c,color="white",readonly=True): 2273 self.SetCellBackgroundColour(r,c,color) 2274 self.SetReadOnly(r,c,isReadOnly=readonly) 2275 2276 def GetSelection(self): 2277 #this is to satisfy structure drawing stuff in G2plt when focus changes 2278 return None 2279 2280 def InstallGridToolTip(self, rowcolhintcallback, 2281 colLblCallback=None,rowLblCallback=None): 2282 '''code to display a tooltip for each item on a grid 2283 from http://wiki.wxpython.org/wxGrid%20ToolTips (buggy!), expanded to 2284 column and row labels using hints from 2285 https://groups.google.com/forum/#!topic/wxPython-users/bm8OARRVDCs 2286 2287 :param function rowcolhintcallback: a routine that returns a text 2288 string depending on the selected row and column, to be used in 2289 explaining grid entries. 2290 :param function colLblCallback: a routine that returns a text 2291 string depending on the selected column, to be used in 2292 explaining grid columns (if None, the default), column labels 2293 do not get a tooltip. 2294 :param function rowLblCallback: a routine that returns a text 2295 string depending on the selected row, to be used in 2296 explaining grid rows (if None, the default), row labels 2297 do not get a tooltip. 2298 ''' 2299 prev_rowcol = [None,None,None] 2300 def OnMouseMotion(event): 2301 # event.GetRow() and event.GetCol() would be nice to have here, 2302 # but as this is a mouse event, not a grid event, they are not 2303 # available and we need to compute them by hand. 2304 x, y = self.CalcUnscrolledPosition(event.GetPosition()) 2305 row = self.YToRow(y) 2306 col = self.XToCol(x) 2307 hinttext = '' 2308 win = event.GetEventObject() 2309 if [row,col,win] == prev_rowcol: # no change from last position 2310 event.Skip() 2311 return 2312 if win == self.GetGridWindow() and row >= 0 and col >= 0: 2313 hinttext = rowcolhintcallback(row, col) 2314 elif win == self.GetGridColLabelWindow() and col >= 0: 2315 if colLblCallback: hinttext = colLblCallback(col) 2316 elif win == self.GetGridRowLabelWindow() and row >= 0: 2317 if rowLblCallback: hinttext = rowLblCallback(row) 2318 else: # this should be the upper left corner, which is empty 2319 event.Skip() 2320 return 2321 if hinttext is None: hinttext = '' 2322 win.SetToolTipString(hinttext) 2323 prev_rowcol[:] = [row,col,win] 2324 event.Skip() 2325 2326 wx.EVT_MOTION(self.GetGridWindow(), OnMouseMotion) 2327 if colLblCallback: wx.EVT_MOTION(self.GetGridColLabelWindow(), OnMouseMotion) 2328 if rowLblCallback: wx.EVT_MOTION(self.GetGridRowLabelWindow(), OnMouseMotion) 2329 2330 ################################################################################ 2331 class Table(wg.PyGridTableBase): 2332 '''Basic data table for use with GSgrid 2333 ''' 2334 def __init__(self, data=[], rowLabels=None, colLabels=None, types = None): 2335 wg.PyGridTableBase.__init__(self) 2336 self.colLabels = colLabels 2337 self.rowLabels = rowLabels 2338 self.dataTypes = types 2339 self.data = data 2340 2341 def AppendRows(self, numRows=1): 2342 self.data.append([]) 2343 return True 2344 2345 def CanGetValueAs(self, row, col, typeName): 2346 if self.dataTypes: 2347 colType = self.dataTypes[col].split(':')[0] 2348 if typeName == colType: 2349 return True 2350 else: 2351 return False 2352 else: 2353 return False 2354 2355 def CanSetValueAs(self, row, col, typeName): 2356 return self.CanGetValueAs(row, col, typeName) 2357 2358 def DeleteRow(self,pos): 2359 data = self.GetData() 2360 self.SetData([]) 2361 new = [] 2362 for irow,row in enumerate(data): 2363 if irow <> pos: 2364 new.append(row) 2365 self.SetData(new) 2366 2367 def GetColLabelValue(self, col): 2368 if self.colLabels: 2369 return self.colLabels[col] 2370 2371 def GetData(self): 2372 data = [] 2373 for row in range(self.GetNumberRows()): 2374 data.append(self.GetRowValues(row)) 2375 return data 2376 2377 def GetNumberCols(self): 2378 try: 2379 return len(self.colLabels) 2380 except TypeError: 2381 return None 2382 2383 def GetNumberRows(self): 2384 return len(self.data) 2385 2386 def GetRowLabelValue(self, row): 2387 if self.rowLabels: 2388 return self.rowLabels[row] 2389 2390 def GetColValues(self, col): 2391 data = [] 2392 for row in range(self.GetNumberRows()): 2393 data.append(self.GetValue(row, col)) 2394 return data 2395 2396 def GetRowValues(self, row): 2397 data = [] 2398 for col in range(self.GetNumberCols()): 2399 data.append(self.GetValue(row, col)) 2400 return data 2401 2402 def GetTypeName(self, row, col): 2403 try: 2404 if self.data[row][col] is None: return None 2405 return self.dataTypes[col] 2406 except (TypeError,IndexError): 2407 return None 2408 2409 def GetValue(self, row, col): 2410 try: 2411 if self.data[row][col] is None: return "" 2412 return self.data[row][col] 2413 except IndexError: 2414 return None 2415 2416 def InsertRows(self, pos, rows): 2417 for row in range(rows): 2418 self.data.insert(pos,[]) 2419 pos += 1 2420 2421 def IsEmptyCell(self,row,col): 2422 try: 2423 return not self.data[row][col] 2424 except IndexError: 2425 return True 2426 2427 def OnKeyPress(self, event): 2428 dellist = self.GetSelectedRows() 2429 if event.GetKeyCode() == wx.WXK_DELETE and dellist: 2430 grid = self.GetView() 2431 for i in dellist: grid.DeleteRow(i) 2432 2433 def SetColLabelValue(self, col, label): 2434 numcols = self.GetNumberCols() 2435 if col > numcols-1: 2436 self.colLabels.append(label) 2437 else: 2438 self.colLabels[col]=label 2439 2440 def SetData(self,data): 2441 for row in range(len(data)): 2442 self.SetRowValues(row,data[row]) 2443 2444 def SetRowLabelValue(self, row, label): 2445 self.rowLabels[row]=label 2446 2447 def SetRowValues(self,row,data): 2448 self.data[row] = data 2449 2450 def SetValue(self, row, col, value): 2451 def innerSetValue(row, col, value): 2452 try: 2453 self.data[row][col] = value 2454 except TypeError: 2455 return 2456 except IndexError: 2457 print row,col,value 2458 # add a new row 2459 if row > self.GetNumberRows(): 2460 self.data.append([''] * self.GetNumberCols()) 2461 elif col > self.GetNumberCols(): 2462 for row in range(self.GetNumberRows): 2463 self.data[row].append('') 2464 print self.data 2465 self.data[row][col] = value 2466 innerSetValue(row, col, value) 2467 2468 ################################################################################ 2469 class GridFractionEditor(wg.PyGridCellEditor): 2470 '''A grid cell editor class that allows entry of values as fractions as well 2471 as sine and cosine values [as s() and c()] 2472 ''' 2473 def __init__(self,grid): 2474 wg.PyGridCellEditor.__init__(self) 2475 2476 def Create(self, parent, id, evtHandler): 2477 self._tc = wx.TextCtrl(parent, id, "") 2478 self._tc.SetInsertionPoint(0) 2479 self.SetControl(self._tc) 2480 2481 if evtHandler: 2482 self._tc.PushEventHandler(evtHandler) 2483 2484 self._tc.Bind(wx.EVT_CHAR, self.OnChar) 2485 2486 def SetSize(self, rect): 2487 self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2, 2488 wx.SIZE_ALLOW_MINUS_ONE) 2489 2490 def BeginEdit(self, row, col, grid): 2491 self.startValue = grid.GetTable().GetValue(row, col) 2492 self._tc.SetValue(str(self.startValue)) 2493 self._tc.SetInsertionPointEnd() 2494 self._tc.SetFocus() 2495 self._tc.SetSelection(0, self._tc.GetLastPosition()) 2496 2497 def EndEdit(self, row, col, grid, oldVal=None): 2498 changed = False 2499 2500 self.nextval = self.startValue 2501 val = self._tc.GetValue().lower() 2502 if val != self.startValue: 2503 changed = True 2504 neg = False 2505 if '-' in val: 2506 neg = True 2507 if '/' in val and '.' not in val: 2508 val += '.' 2509 elif 's' in val and not 'sind(' in val: 2510 if neg: 2511 val = '-sind('+val.strip('-s')+')' 2512 else: 2513 val = 'sind('+val.strip('s')+')' 2514 elif 'c' in val and not 'cosd(' in val: 2515 if neg: 2516 val = '-cosd('+val.strip('-c')+')' 2517 else: 2518 val = 'cosd('+val.strip('c')+')' 2519 try: 2520 self.nextval = val = float(eval(val)) 2521 except (SyntaxError,NameError,ZeroDivisionError): 2522 val = self.startValue 2523 return None 2524 2525 if oldVal is None: # this arg appears in 2.9+; before, we should go ahead & change the table 2526 grid.GetTable().SetValue(row, col, val) # update the table 2527 # otherwise self.ApplyEdit gets called 2528 2529 self.startValue = '' 2530 self._tc.SetValue('') 2531 return changed 2532 2533 def ApplyEdit(self, row, col, grid): 2534 """ Called only in wx >= 2.9 2535 Save the value of the control into the grid if EndEdit() returns as True 2536 """ 2537 grid.GetTable().SetValue(row, col, self.nextval) # update the table 2538 2539 def Reset(self): 2540 self._tc.SetValue(self.startValue) 2541 self._tc.SetInsertionPointEnd() 2542 2543 def Clone(self): 2544 return GridFractionEditor(grid) 2545 2546 def StartingKey(self, evt): 2547 self.OnChar(evt) 2548 if evt.GetSkipped(): 2549 self._tc.EmulateKeyPress(evt) 2550 2551 def OnChar(self, evt): 2552 key = evt.GetKeyCode() 2553 if key == 15: 2554 return 2555 if key > 255: 2556 evt.Skip() 2557 return 2558 char = chr(key) 2559 if char in '.+-/0123456789cosind()': 2560 self._tc.WriteText(char) 2561 else: 2562 evt.Skip() 2563 2564 ################################################################################ 2565 ##### Customized Notebook 2566 ################################################################################ 2567 class GSNoteBook(wx.aui.AuiNotebook): 2568 '''Notebook used in various locations; implemented with wx.aui extension 2569 ''' 2570 def __init__(self, parent, name='',size = None): 2571 wx.aui.AuiNotebook.__init__(self, parent, -1, 2572 style=wx.aui.AUI_NB_TOP | 2573 wx.aui.AUI_NB_SCROLL_BUTTONS) 2574 if size: self.SetSize(size) 2575 self.parent = parent 2576 self.PageChangeHandler = None 2577 2578 def PageChangeEvent(self,event): 2579 G2frame = self.parent.G2frame 2580 page = event.GetSelection() 2581 if self.PageChangeHandler: 2582 if log.LogInfo['Logging']: 2583 log.MakeTabLog( 2584 G2frame.dataFrame.GetTitle(), 2585 G2frame.dataDisplay.GetPageText(page) 2586 ) 2587 self.PageChangeHandler(event) 2588 2589 def Bind(self,eventtype,handler,*args,**kwargs): 2590 '''Override the Bind() function so that page change events can be trapped 2591 ''' 2592 if eventtype == wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED: 2593 self.PageChangeHandler = handler 2594 wx.aui.AuiNotebook.Bind(self,eventtype,self.PageChangeEvent) 2595 return 2596 wx.aui.AuiNotebook.Bind(self,eventtype,handler,*args,**kwargs) 2597 2598 def Clear(self): 2599 GSNoteBook.DeleteAllPages(self) 2600 2601 def FindPage(self,name): 2602 numPage = self.GetPageCount() 2603 for page in range(numPage): 2604 if self.GetPageText(page) == name: 2605 return page 2606 2607 def ChangeSelection(self,page): 2608 # in wx.Notebook ChangeSelection is like SetSelection, but it 2609 # does not invoke the event related to pressing the tab button 2610 # I don't see a way to do that in aui. 2611 oldPage = self.GetSelection() 2612 self.SetSelection(page) 2613 return oldPage 2614 2615 # def __getattribute__(self,name): 2616 # '''This method provides a way to print out a message every time 2617 # that a method in a class is called -- to see what all the calls 2618 # might be, or where they might be coming from. 2619 # Cute trick for debugging! 2620 # ''' 2621 # attr = object.__getattribute__(self, name) 2622 # if hasattr(attr, '__call__'): 2623 # def newfunc(*args, **kwargs): 2624 # print('GSauiNoteBook calling %s' %attr.__name__) 2625 # result = attr(*args, **kwargs) 2626 # return result 2627 # return newfunc 2628 # else: 2629 # return attr 2630 2631 ################################################################################ 1751 2632 #### Help support routines 1752 2633 ################################################################################ … … 2117 2998 msg1 = msg.replace('\n ','\n') 2118 2999 return msg.replace('\n\t','\n') 2119 2120 def G2MessageBox(parent,msg,title='Error'):2121 '''Simple code to display a error or warning message2122 '''2123 dlg = wx.MessageDialog(parent,StripIndents(msg), title, wx.OK)2124 dlg.ShowModal()2125 dlg.Destroy()2126 3000 2127 3001 ################################################################################ … … 2204 3078 'Get the version number in the dialog' 2205 3079 return self.spin.GetValue() 3080 2206 3081 ################################################################################ 2207 3082 #### Display Help information … … 2246 3121 else: 2247 3122 webbrowser.open(pfx+helplink, new=0, autoraise=True) 3123 2248 3124 def ShowWebPage(URL,frame): 2249 3125 '''Called to show a tutorial web page. … … 2277 3153 else: 2278 3154 webbrowser.open(pfx+URL, new=0, autoraise=True) 3155 2279 3156 ################################################################################ 2280 #### Tutorials s elector3157 #### Tutorials support 2281 3158 ################################################################################ 2282 3159 G2BaseURL = "https://subversion.xray.aps.anl.gov/pyGSAS" -
trunk/GSASIIgrid.py
r1822 r1831 12 12 -------------------------------- 13 13 14 Note that a number of routines here should be moved to GSASIIctrls eventually, such as15 G2LoggedButton, EnumSelector, G2ChoiceButton, SingleFloatDialog, SingleStringDialog,16 MultiStringDialog, G2ColumnIDDialog, ItemSelector, GridFractionEditor17 18 Probably SGMessageBox, SymOpDialog, DisAglDialog, too.19 20 14 ''' 21 15 import wx 22 16 import wx.grid as wg 23 import wx.wizard as wz24 import wx.aui17 #import wx.wizard as wz 18 #import wx.aui 25 19 import wx.lib.scrolledpanel as wxscroll 26 20 import time … … 156 150 157 151 VERY_LIGHT_GREY = wx.Colour(235,235,235) 152 153 # Aliases for Classes/Functions moved to GSASIIctrls, all should be tracked down but leaving as a reminder 154 #SingleFloatDialog = G2G.SingleFloatDialog 155 #SingleStringDialog = G2G.SingleStringDialog 156 #MultiStringDialog = G2G.MultiStringDialog 157 #G2ColumnIDDialog = G2G.G2ColumnIDDialog 158 #ItemSelector = G2G.ItemSelector 159 #HorizontalLine = G2G.HorizontalLine 160 #G2LoggedButton = G2G.G2LoggedButton 161 #EnumSelector = G2G.EnumSelector 162 #G2ChoiceButton = G2G.G2ChoiceButton 163 #GSGrid = G2G.GSGrid 164 #Table = G2G.Table 165 #GridFractionEditor = G2G.GridFractionEditor 166 #GSNoteBook = G2G.GSNoteBook 167 168 # Should SGMessageBox, SymOpDialog, DisAglDialog be moved? 169 158 170 ################################################################################ 159 171 #### GSAS-II class definitions … … 206 218 self.ShowModal() 207 219 return 208 209 class G2LoggedButton(wx.Button):210 '''A version of wx.Button that creates logging events. Bindings are saved211 in the object, and are looked up rather than directly set with a bind.212 An index to these buttons is saved as log.ButtonBindingLookup213 :param wx.Panel parent: parent widget214 :param int id: Id for button215 :param str label: label for button216 :param str locationcode: a label used internally to uniquely indentify the button217 :param function handler: a routine to call when the button is pressed218 '''219 def __init__(self,parent,id=wx.ID_ANY,label='',locationcode='',220 handler=None,*args,**kwargs):221 super(self.__class__,self).__init__(parent,id,label,*args,**kwargs)222 self.label = label223 self.handler = handler224 self.locationcode = locationcode225 key = locationcode + '+' + label # hash code to find button226 self.Bind(wx.EVT_BUTTON,self.onPress)227 log.ButtonBindingLookup[key] = self228 def onPress(self,event):229 'create log event and call handler'230 log.MakeButtonLog(self.locationcode,self.label)231 self.handler(event)232 233 ################################################################################234 ################################################################################235 class EnumSelector(wx.ComboBox):236 '''A customized :class:`wxpython.ComboBox` that selects items from a list237 of choices, but sets a dict (list) entry to the corresponding238 entry from the input list of values.239 240 :param wx.Panel parent: the parent to the :class:`~wxpython.ComboBox` (usually a241 frame or panel)242 :param dict dct: a dict (or list) to contain the value set243 for the :class:`~wxpython.ComboBox`.244 :param item: the dict key (or list index) where ``dct[item]`` will245 be set to the value selected in the :class:`~wxpython.ComboBox`. Also, dct[item]246 contains the starting value shown in the widget. If the value247 does not match an entry in :data:`values`, the first value248 in :data:`choices` is used as the default, but ``dct[item]`` is249 not changed.250 :param list choices: a list of choices to be displayed to the251 user such as252 ::253 254 ["default","option 1","option 2",]255 256 Note that these options will correspond to the entries in257 :data:`values` (if specified) item by item.258 :param list values: a list of values that correspond to259 the options in :data:`choices`, such as260 ::261 262 [0,1,2]263 264 The default for :data:`values` is to use the same list as265 specified for :data:`choices`.266 :param (other): additional keyword arguments accepted by267 :class:`~wxpython.ComboBox` can be specified.268 '''269 def __init__(self,parent,dct,item,choices,values=None,**kw):270 if values is None:271 values = choices272 if dct[item] in values:273 i = values.index(dct[item])274 else:275 i = 0276 startval = choices[i]277 wx.ComboBox.__init__(self,parent,wx.ID_ANY,startval,278 choices = choices,279 style=wx.CB_DROPDOWN|wx.CB_READONLY,280 **kw)281 self.choices = choices282 self.values = values283 self.dct = dct284 self.item = item285 self.Bind(wx.EVT_COMBOBOX, self.onSelection)286 def onSelection(self,event):287 # respond to a selection by setting the enum value in the CIF dictionary288 if self.GetValue() in self.choices: # should always be true!289 self.dct[self.item] = self.values[self.choices.index(self.GetValue())]290 else:291 self.dct[self.item] = self.values[0] # unknown292 293 ################################################################################294 ################################################################################295 class G2ChoiceButton(wx.Choice):296 '''A customized version of a wx.Choice that automatically initializes297 the control to match a supplied value and saves the choice directly298 into an array or list. Optionally a function can be called each time a299 choice is selected. The widget can be used with an array item that is set to300 to the choice by number (``indLoc[indKey]``) or by string value301 (``strLoc[strKey]``) or both. The initial value is taken from ``indLoc[indKey]``302 if not None or ``strLoc[strKey]`` if not None.303 304 :param wx.Panel parent: name of panel or frame that will be305 the parent to the widget. Can be None.306 :param list choiceList: a list or tuple of choices to offer the user.307 :param dict/list indLoc: a dict or list with the initial value to be308 placed in the Choice button. If this is None, this is ignored.309 :param int/str indKey: the dict key or the list index for the value to be310 edited by the Choice button. If indLoc is not None then this311 must be specified and the ``indLoc[indKey]`` will be set. If the value312 for ``indLoc[indKey]`` is not None, it should be an integer in313 range(len(choiceList)). The Choice button will be initialized to the314 choice corresponding to the value in this element if not None.315 :param dict/list strLoc: a dict or list with the string value corresponding to316 indLoc/indKey. Default (None) means that this is not used.317 :param int/str strKey: the dict key or the list index for the string value318 The ``strLoc[strKey]`` element must exist or strLoc must be None (default).319 :param function onChoice: name of a function to call when the choice is made.320 '''321 def __init__(self,parent,choiceList,indLoc=None,indKey=None,strLoc=None,strKey=None,322 onChoice=None,**kwargs):323 wx.Choice.__init__(self,parent,choices=choiceList,id=wx.ID_ANY,**kwargs)324 self.choiceList = choiceList325 self.indLoc = indLoc326 self.indKey = indKey327 self.strLoc = strLoc328 self.strKey = strKey329 self.onChoice = None330 self.SetSelection(wx.NOT_FOUND)331 if self.indLoc is not None and self.indLoc.get(self.indKey) is not None:332 self.SetSelection(self.indLoc[self.indKey])333 if self.strLoc is not None:334 self.strLoc[self.strKey] = self.GetStringSelection()335 log.LogVarChange(self.strLoc,self.strKey)336 elif self.strLoc is not None and self.strLoc.get(self.strKey) is not None:337 try:338 self.SetSelection(choiceList.index(self.strLoc[self.strKey]))339 if self.indLoc is not None:340 self.indLoc[self.indKey] = self.GetSelection()341 log.LogVarChange(self.indLoc,self.indKey)342 except ValueError:343 pass344 self.Bind(wx.EVT_CHOICE, self._OnChoice)345 #if self.strLoc is not None: # make sure strLoc gets initialized346 # self._OnChoice(None) # note that onChoice will not be called347 self.onChoice = onChoice348 def _OnChoice(self,event):349 if self.indLoc is not None:350 self.indLoc[self.indKey] = self.GetSelection()351 log.LogVarChange(self.indLoc,self.indKey)352 if self.strLoc is not None:353 self.strLoc[self.strKey] = self.GetStringSelection()354 log.LogVarChange(self.strLoc,self.strKey)355 if self.onChoice:356 self.onChoice()357 220 358 221 ################################################################################ … … 577 440 self.Draw(self.data) 578 441 579 class SingleFloatDialog(wx.Dialog):580 'Dialog to obtain a single float value from user'581 def __init__(self,parent,title,prompt,value,limits=[0.,1.],format='%.5g'):582 wx.Dialog.__init__(self,parent,-1,title,583 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)584 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!585 self.limits = limits586 self.value = value587 self.prompt = prompt588 self.format = format589 self.Draw()590 591 def Draw(self):592 593 def OnValItem(event):594 try:595 val = float(valItem.GetValue())596 if val < self.limits[0] or val > self.limits[1]:597 raise ValueError598 except ValueError:599 val = self.value600 self.value = val601 valItem.SetValue(self.format%(self.value))602 603 self.panel.Destroy()604 self.panel = wx.Panel(self)605 mainSizer = wx.BoxSizer(wx.VERTICAL)606 mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER)607 valItem = wx.TextCtrl(self.panel,-1,value=self.format%(self.value),style=wx.TE_PROCESS_ENTER)608 mainSizer.Add(valItem,0,wx.ALIGN_CENTER)609 valItem.Bind(wx.EVT_TEXT_ENTER,OnValItem)610 valItem.Bind(wx.EVT_KILL_FOCUS,OnValItem)611 OkBtn = wx.Button(self.panel,-1,"Ok")612 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)613 CancelBtn = wx.Button(self.panel,-1,'Cancel')614 CancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)615 btnSizer = wx.BoxSizer(wx.HORIZONTAL)616 btnSizer.Add((20,20),1)617 btnSizer.Add(OkBtn)618 btnSizer.Add(CancelBtn)619 btnSizer.Add((20,20),1)620 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)621 self.panel.SetSizer(mainSizer)622 self.panel.Fit()623 self.Fit()624 625 def GetValue(self):626 return self.value627 628 def OnOk(self,event):629 parent = self.GetParent()630 parent.Raise()631 self.EndModal(wx.ID_OK)632 633 def OnCancel(self,event):634 parent = self.GetParent()635 parent.Raise()636 self.EndModal(wx.ID_CANCEL)637 638 ################################################################################639 class SingleStringDialog(wx.Dialog):640 '''Dialog to obtain a single string value from user641 642 :param wx.Frame parent: name of parent frame643 :param str title: title string for dialog644 :param str prompt: string to tell use what they are inputting645 :param str value: default input value, if any646 '''647 def __init__(self,parent,title,prompt,value='',size=(200,-1)):648 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,649 pos=wx.DefaultPosition,650 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)651 self.value = value652 self.prompt = prompt653 self.CenterOnParent()654 self.panel = wx.Panel(self)655 mainSizer = wx.BoxSizer(wx.VERTICAL)656 mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER)657 self.valItem = wx.TextCtrl(self.panel,-1,value=self.value,size=size)658 mainSizer.Add(self.valItem,0,wx.ALIGN_CENTER)659 btnsizer = wx.StdDialogButtonSizer()660 OKbtn = wx.Button(self.panel, wx.ID_OK)661 OKbtn.SetDefault()662 btnsizer.AddButton(OKbtn)663 btn = wx.Button(self.panel, wx.ID_CANCEL)664 btnsizer.AddButton(btn)665 btnsizer.Realize()666 mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER)667 self.panel.SetSizer(mainSizer)668 self.panel.Fit()669 self.Fit()670 671 def Show(self):672 '''Use this method after creating the dialog to post it673 :returns: True if the user pressed OK; False if the User pressed Cancel674 '''675 if self.ShowModal() == wx.ID_OK:676 self.value = self.valItem.GetValue()677 return True678 else:679 return False680 681 def GetValue(self):682 '''Use this method to get the value entered by the user683 :returns: string entered by user684 '''685 return self.value686 687 ################################################################################688 class MultiStringDialog(wx.Dialog):689 '''Dialog to obtain a multi string values from user690 691 :param wx.Frame parent: name of parent frame692 :param str title: title string for dialog693 :param str prompts: strings to tell use what they are inputting694 :param str values: default input values, if any695 '''696 def __init__(self,parent,title,prompts,values=[]): #,size=(200,-1)?697 698 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,699 pos=wx.DefaultPosition,700 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)701 self.values = values702 self.prompts = prompts703 self.CenterOnParent()704 self.panel = wx.Panel(self)705 mainSizer = wx.BoxSizer(wx.VERTICAL)706 promptSizer = wx.FlexGridSizer(0,2,5,5)707 self.Indx = {}708 for prompt,value in zip(prompts,values):709 promptSizer.Add(wx.StaticText(self.panel,-1,prompt),0,WACV)710 valItem = wx.TextCtrl(self.panel,-1,value=value,style=wx.TE_PROCESS_ENTER)711 self.Indx[valItem.GetId()] = prompt712 valItem.Bind(wx.EVT_TEXT,self.newValue)713 promptSizer.Add(valItem,0,WACV)714 mainSizer.Add(promptSizer,0)715 btnsizer = wx.StdDialogButtonSizer()716 OKbtn = wx.Button(self.panel, wx.ID_OK)717 OKbtn.SetDefault()718 btnsizer.AddButton(OKbtn)719 btn = wx.Button(self.panel, wx.ID_CANCEL)720 btnsizer.AddButton(btn)721 btnsizer.Realize()722 mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER)723 self.panel.SetSizer(mainSizer)724 self.panel.Fit()725 self.Fit()726 727 def newValue(self,event):728 Obj = event.GetEventObject()729 item = self.Indx[Obj.GetId()]730 id = self.prompts.index(item)731 self.values[id] = Obj.GetValue()732 733 def Show(self):734 '''Use this method after creating the dialog to post it735 :returns: True if the user pressed OK; False if the User pressed Cancel736 '''737 if self.ShowModal() == wx.ID_OK:738 return True739 else:740 return False741 742 def GetValues(self):743 '''Use this method to get the value entered by the user744 :returns: string entered by user745 '''746 return self.values747 748 ################################################################################749 750 class G2ColumnIDDialog(wx.Dialog):751 '''A dialog for matching column data to desired items; some columns may be ignored.752 753 :param wx.Frame ParentFrame: reference to parent frame754 :param str title: heading above list of choices755 :param str header: Title to place on window frame756 :param list ChoiceList: a list of possible choices for the columns757 :param list ColumnData: lists of column data to be matched with ChoiceList758 :param bool monoFont: If False (default), use a variable-spaced font;759 if True use a equally-spaced font.760 :param kw: optional keyword parameters for the wx.Dialog may761 be included such as size [which defaults to `(320,310)`] and762 style (which defaults to ``wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.CENTRE | wx.OK | wx.CANCEL``);763 note that ``wx.OK`` and ``wx.CANCEL`` controls764 the presence of the eponymous buttons in the dialog.765 :returns: the name of the created dialog766 767 '''768 769 def __init__(self,parent, title, header,Comments,ChoiceList, ColumnData,770 monoFont=False, **kw):771 772 def OnOk(sevent):773 OK = True774 selCols = []775 for col in self.sel:776 item = col.GetValue()777 if item != ' ' and item in selCols:778 OK = False779 break780 else:781 selCols.append(item)782 parent = self.GetParent()783 if not OK:784 parent.ErrorDialog('Duplicate',item+' selected more than once')785 return786 parent.Raise()787 self.EndModal(wx.ID_OK)788 789 def OnModify(event):790 Obj = event.GetEventObject()791 icol,colData = Indx[Obj.GetId()]792 modify = Obj.GetValue()793 if not modify:794 return795 print 'Modify column',icol,' by', modify796 for i,item in enumerate(self.ColumnData[icol]):797 self.ColumnData[icol][i] = str(eval(item+modify))798 colData.SetValue('\n'.join(self.ColumnData[icol]))799 Obj.SetValue('')800 801 # process keyword parameters, notably style802 options = {'size':(600,310), # default Frame keywords803 'style':wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE| wx.OK | wx.CANCEL,804 }805 options.update(kw)806 self.Comments = ''.join(Comments)807 self.ChoiceList = ChoiceList808 self.ColumnData = ColumnData809 nCol = len(ColumnData)810 if options['style'] & wx.OK:811 useOK = True812 options['style'] ^= wx.OK813 else:814 useOK = False815 if options['style'] & wx.CANCEL:816 useCANCEL = True817 options['style'] ^= wx.CANCEL818 else:819 useCANCEL = False820 # create the dialog frame821 wx.Dialog.__init__(self,parent,wx.ID_ANY,header,**options)822 panel = wxscroll.ScrolledPanel(self)823 # fill the dialog824 Sizer = wx.BoxSizer(wx.VERTICAL)825 Sizer.Add((-1,5))826 Sizer.Add(wx.StaticText(panel,label=title),0,WACV)827 if self.Comments:828 Sizer.Add(wx.StaticText(panel,label=' Header lines:'),0,WACV)829 Sizer.Add(wx.TextCtrl(panel,value=self.Comments,size=(200,-1),830 style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP),0,wx.ALL|wx.EXPAND|WACV,8)831 columnsSizer = wx.FlexGridSizer(0,nCol,5,10)832 self.sel = []833 self.mod = []834 Indx = {}835 for icol,col in enumerate(self.ColumnData):836 colSizer = wx.BoxSizer(wx.VERTICAL)837 colSizer.Add(wx.StaticText(panel,label=' Column #%d Select:'%(icol)),0,WACV)838 self.sel.append(wx.ComboBox(panel,value=' ',choices=self.ChoiceList,style=wx.CB_READONLY|wx.CB_DROPDOWN))839 colSizer.Add(self.sel[-1])840 colData = wx.TextCtrl(panel,value='\n'.join(self.ColumnData[icol]),size=(120,-1),841 style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP)842 colSizer.Add(colData,0,WACV)843 colSizer.Add(wx.StaticText(panel,label=' Modify by:'),0,WACV)844 mod = wx.TextCtrl(panel,size=(120,-1),value='',style=wx.TE_PROCESS_ENTER)845 mod.Bind(wx.EVT_TEXT_ENTER,OnModify)846 mod.Bind(wx.EVT_KILL_FOCUS,OnModify)847 Indx[mod.GetId()] = [icol,colData]848 colSizer.Add(mod,0,WACV)849 columnsSizer.Add(colSizer)850 Sizer.Add(columnsSizer)851 Sizer.Add(wx.StaticText(panel,label=' For modify by, enter arithmetic string eg. "-12345.67". "+","-","*","/","**" all allowed'),0,WACV)852 Sizer.Add((-1,10))853 # OK/Cancel buttons854 btnsizer = wx.StdDialogButtonSizer()855 if useOK:856 self.OKbtn = wx.Button(panel, wx.ID_OK)857 self.OKbtn.SetDefault()858 btnsizer.AddButton(self.OKbtn)859 self.OKbtn.Bind(wx.EVT_BUTTON, OnOk)860 if useCANCEL:861 btn = wx.Button(panel, wx.ID_CANCEL)862 btnsizer.AddButton(btn)863 btnsizer.Realize()864 Sizer.Add((-1,5))865 Sizer.Add(btnsizer,0,wx.ALIGN_LEFT,20)866 Sizer.Add((-1,5))867 # OK done, let's get outa here868 panel.SetSizer(Sizer)869 panel.SetAutoLayout(1)870 panel.SetupScrolling()871 Size = [450,375]872 panel.SetSize(Size)873 Size[0] += 25; Size[1]+= 25874 self.SetSize(Size)875 876 def GetSelection(self):877 'Returns the selected sample parm for each column'878 selCols = []879 for item in self.sel:880 selCols.append(item.GetValue())881 return selCols,self.ColumnData882 883 ################################################################################884 885 def ItemSelector(ChoiceList, ParentFrame=None,886 title='Select an item',887 size=None, header='Item Selector',888 useCancel=True,multiple=False):889 ''' Provide a wx dialog to select a single item or multiple items from list of choices890 891 :param list ChoiceList: a list of choices where one will be selected892 :param wx.Frame ParentFrame: Name of parent frame (default None)893 :param str title: heading above list of choices (default 'Select an item')894 :param wx.Size size: Size for dialog to be created (default None -- size as needed)895 :param str header: Title to place on window frame (default 'Item Selector')896 :param bool useCancel: If True (default) both the OK and Cancel buttons are offered897 :param bool multiple: If True then multiple items can be selected (default False)898 899 :returns: the selection index or None or a selection list if multiple is true900 '''901 if multiple:902 if useCancel:903 dlg = G2G.G2MultiChoiceDialog(904 ParentFrame,title, header, ChoiceList)905 else:906 dlg = G2G.G2MultiChoiceDialog(907 ParentFrame,title, header, ChoiceList,908 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE)909 else:910 if useCancel:911 dlg = wx.SingleChoiceDialog(912 ParentFrame,title, header, ChoiceList)913 else:914 dlg = wx.SingleChoiceDialog(915 ParentFrame,title, header,ChoiceList,916 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE)917 if size: dlg.SetSize(size)918 if dlg.ShowModal() == wx.ID_OK:919 if multiple:920 dlg.Destroy()921 return dlg.GetSelections()922 else:923 dlg.Destroy()924 return dlg.GetSelection()925 else:926 dlg.Destroy()927 return None928 dlg.Destroy()929 930 ################################################################################931 class GridFractionEditor(wg.PyGridCellEditor):932 '''A grid cell editor class that allows entry of values as fractions as well933 as sine and cosine values [as s() and c()]934 '''935 def __init__(self,grid):936 wg.PyGridCellEditor.__init__(self)937 938 def Create(self, parent, id, evtHandler):939 self._tc = wx.TextCtrl(parent, id, "")940 self._tc.SetInsertionPoint(0)941 self.SetControl(self._tc)942 943 if evtHandler:944 self._tc.PushEventHandler(evtHandler)945 946 self._tc.Bind(wx.EVT_CHAR, self.OnChar)947 948 def SetSize(self, rect):949 self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2,950 wx.SIZE_ALLOW_MINUS_ONE)951 952 def BeginEdit(self, row, col, grid):953 self.startValue = grid.GetTable().GetValue(row, col)954 self._tc.SetValue(str(self.startValue))955 self._tc.SetInsertionPointEnd()956 self._tc.SetFocus()957 self._tc.SetSelection(0, self._tc.GetLastPosition())958 959 def EndEdit(self, row, col, grid, oldVal=None):960 changed = False961 962 self.nextval = self.startValue963 val = self._tc.GetValue().lower()964 if val != self.startValue:965 changed = True966 neg = False967 if '-' in val:968 neg = True969 if '/' in val and '.' not in val:970 val += '.'971 elif 's' in val and not 'sind(' in val:972 if neg:973 val = '-sind('+val.strip('-s')+')'974 else:975 val = 'sind('+val.strip('s')+')'976 elif 'c' in val and not 'cosd(' in val:977 if neg:978 val = '-cosd('+val.strip('-c')+')'979 else:980 val = 'cosd('+val.strip('c')+')'981 try:982 self.nextval = val = float(eval(val))983 except (SyntaxError,NameError,ZeroDivisionError):984 val = self.startValue985 return None986 987 if oldVal is None: # this arg appears in 2.9+; before, we should go ahead & change the table988 grid.GetTable().SetValue(row, col, val) # update the table989 # otherwise self.ApplyEdit gets called990 991 self.startValue = ''992 self._tc.SetValue('')993 return changed994 995 def ApplyEdit(self, row, col, grid):996 """ Called only in wx >= 2.9997 Save the value of the control into the grid if EndEdit() returns as True998 """999 grid.GetTable().SetValue(row, col, self.nextval) # update the table1000 1001 def Reset(self):1002 self._tc.SetValue(self.startValue)1003 self._tc.SetInsertionPointEnd()1004 1005 def Clone(self):1006 return GridFractionEditor(grid)1007 1008 def StartingKey(self, evt):1009 self.OnChar(evt)1010 if evt.GetSkipped():1011 self._tc.EmulateKeyPress(evt)1012 1013 def OnChar(self, evt):1014 key = evt.GetKeyCode()1015 if key == 15:1016 return1017 if key > 255:1018 evt.Skip()1019 return1020 char = chr(key)1021 if char in '.+-/0123456789cosind()':1022 self._tc.WriteText(char)1023 else:1024 evt.Skip()1025 1026 442 ################################################################################ 1027 443 class ShowLSParms(wx.Dialog): … … 1927 1343 self.DestroyChildren() 1928 1344 1345 1929 1346 ################################################################################ 1930 ##### GSNotebook 1931 ################################################################################ 1932 1933 class GSNoteBook(wx.aui.AuiNotebook): 1934 '''Notebook used in various locations; implemented with wx.aui extension 1935 ''' 1936 def __init__(self, parent, name='',size = None): 1937 wx.aui.AuiNotebook.__init__(self, parent, -1, 1938 style=wx.aui.AUI_NB_TOP | 1939 wx.aui.AUI_NB_SCROLL_BUTTONS) 1940 if size: self.SetSize(size) 1941 self.parent = parent 1942 self.PageChangeHandler = None 1943 1944 def PageChangeEvent(self,event): 1945 G2frame = self.parent.G2frame 1946 page = event.GetSelection() 1947 if self.PageChangeHandler: 1948 if log.LogInfo['Logging']: 1949 log.MakeTabLog( 1950 G2frame.dataFrame.GetTitle(), 1951 G2frame.dataDisplay.GetPageText(page) 1952 ) 1953 self.PageChangeHandler(event) 1954 1955 def Bind(self,eventtype,handler,*args,**kwargs): 1956 '''Override the Bind() function so that page change events can be trapped 1957 ''' 1958 if eventtype == wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED: 1959 self.PageChangeHandler = handler 1960 wx.aui.AuiNotebook.Bind(self,eventtype,self.PageChangeEvent) 1961 return 1962 wx.aui.AuiNotebook.Bind(self,eventtype,handler,*args,**kwargs) 1963 1964 def Clear(self): 1965 GSNoteBook.DeleteAllPages(self) 1966 1967 def FindPage(self,name): 1968 numPage = self.GetPageCount() 1969 for page in range(numPage): 1970 if self.GetPageText(page) == name: 1971 return page 1972 1973 def ChangeSelection(self,page): 1974 # in wx.Notebook ChangeSelection is like SetSelection, but it 1975 # does not invoke the event related to pressing the tab button 1976 # I don't see a way to do that in aui. 1977 oldPage = self.GetSelection() 1978 self.SetSelection(page) 1979 return oldPage 1980 1981 # def __getattribute__(self,name): 1982 # '''This method provides a way to print out a message every time 1983 # that a method in a class is called -- to see what all the calls 1984 # might be, or where they might be coming from. 1985 # Cute trick for debugging! 1986 # ''' 1987 # attr = object.__getattribute__(self, name) 1988 # if hasattr(attr, '__call__'): 1989 # def newfunc(*args, **kwargs): 1990 # print('GSauiNoteBook calling %s' %attr.__name__) 1991 # result = attr(*args, **kwargs) 1992 # return result 1993 # return newfunc 1994 # else: 1995 # return attr 1996 1997 ################################################################################ 1998 ##### GSGrid 1999 ################################################################################ 2000 2001 class GSGrid(wg.Grid): 2002 '''Basic wx.Grid implementation 2003 ''' 2004 def __init__(self, parent, name=''): 2005 wg.Grid.__init__(self,parent,-1,name=name) 2006 #self.SetSize(parent.GetClientSize()) 2007 # above removed to speed drawing of initial grid 2008 # does not appear to be needed 2009 2010 def Clear(self): 2011 wg.Grid.ClearGrid(self) 2012 2013 def SetCellReadOnly(self,r,c,readonly=True): 2014 self.SetReadOnly(r,c,isReadOnly=readonly) 2015 2016 def SetCellStyle(self,r,c,color="white",readonly=True): 2017 self.SetCellBackgroundColour(r,c,color) 2018 self.SetReadOnly(r,c,isReadOnly=readonly) 2019 2020 def GetSelection(self): 2021 #this is to satisfy structure drawing stuff in G2plt when focus changes 2022 return None 2023 2024 def InstallGridToolTip(self, rowcolhintcallback, 2025 colLblCallback=None,rowLblCallback=None): 2026 '''code to display a tooltip for each item on a grid 2027 from http://wiki.wxpython.org/wxGrid%20ToolTips (buggy!), expanded to 2028 column and row labels using hints from 2029 https://groups.google.com/forum/#!topic/wxPython-users/bm8OARRVDCs 2030 2031 :param function rowcolhintcallback: a routine that returns a text 2032 string depending on the selected row and column, to be used in 2033 explaining grid entries. 2034 :param function colLblCallback: a routine that returns a text 2035 string depending on the selected column, to be used in 2036 explaining grid columns (if None, the default), column labels 2037 do not get a tooltip. 2038 :param function rowLblCallback: a routine that returns a text 2039 string depending on the selected row, to be used in 2040 explaining grid rows (if None, the default), row labels 2041 do not get a tooltip. 2042 ''' 2043 prev_rowcol = [None,None,None] 2044 def OnMouseMotion(event): 2045 # event.GetRow() and event.GetCol() would be nice to have here, 2046 # but as this is a mouse event, not a grid event, they are not 2047 # available and we need to compute them by hand. 2048 x, y = self.CalcUnscrolledPosition(event.GetPosition()) 2049 row = self.YToRow(y) 2050 col = self.XToCol(x) 2051 hinttext = '' 2052 win = event.GetEventObject() 2053 if [row,col,win] == prev_rowcol: # no change from last position 2054 event.Skip() 2055 return 2056 if win == self.GetGridWindow() and row >= 0 and col >= 0: 2057 hinttext = rowcolhintcallback(row, col) 2058 elif win == self.GetGridColLabelWindow() and col >= 0: 2059 if colLblCallback: hinttext = colLblCallback(col) 2060 elif win == self.GetGridRowLabelWindow() and row >= 0: 2061 if rowLblCallback: hinttext = rowLblCallback(row) 2062 else: # this should be the upper left corner, which is empty 2063 event.Skip() 2064 return 2065 if hinttext is None: hinttext = '' 2066 win.SetToolTipString(hinttext) 2067 prev_rowcol[:] = [row,col,win] 2068 event.Skip() 2069 2070 wx.EVT_MOTION(self.GetGridWindow(), OnMouseMotion) 2071 if colLblCallback: wx.EVT_MOTION(self.GetGridColLabelWindow(), OnMouseMotion) 2072 if rowLblCallback: wx.EVT_MOTION(self.GetGridRowLabelWindow(), OnMouseMotion) 2073 2074 ################################################################################ 2075 ##### Table 2076 ################################################################################ 2077 2078 class Table(wg.PyGridTableBase): 2079 '''Basic data table for use with GSgrid 2080 ''' 2081 def __init__(self, data=[], rowLabels=None, colLabels=None, types = None): 2082 wg.PyGridTableBase.__init__(self) 2083 self.colLabels = colLabels 2084 self.rowLabels = rowLabels 2085 self.dataTypes = types 2086 self.data = data 2087 2088 def AppendRows(self, numRows=1): 2089 self.data.append([]) 2090 return True 2091 2092 def CanGetValueAs(self, row, col, typeName): 2093 if self.dataTypes: 2094 colType = self.dataTypes[col].split(':')[0] 2095 if typeName == colType: 2096 return True 2097 else: 2098 return False 2099 else: 2100 return False 2101 2102 def CanSetValueAs(self, row, col, typeName): 2103 return self.CanGetValueAs(row, col, typeName) 2104 2105 def DeleteRow(self,pos): 2106 data = self.GetData() 2107 self.SetData([]) 2108 new = [] 2109 for irow,row in enumerate(data): 2110 if irow <> pos: 2111 new.append(row) 2112 self.SetData(new) 2113 2114 def GetColLabelValue(self, col): 2115 if self.colLabels: 2116 return self.colLabels[col] 2117 2118 def GetData(self): 2119 data = [] 2120 for row in range(self.GetNumberRows()): 2121 data.append(self.GetRowValues(row)) 2122 return data 2123 2124 def GetNumberCols(self): 2125 try: 2126 return len(self.colLabels) 2127 except TypeError: 2128 return None 2129 2130 def GetNumberRows(self): 2131 return len(self.data) 2132 2133 def GetRowLabelValue(self, row): 2134 if self.rowLabels: 2135 return self.rowLabels[row] 2136 2137 def GetColValues(self, col): 2138 data = [] 2139 for row in range(self.GetNumberRows()): 2140 data.append(self.GetValue(row, col)) 2141 return data 2142 2143 def GetRowValues(self, row): 2144 data = [] 2145 for col in range(self.GetNumberCols()): 2146 data.append(self.GetValue(row, col)) 2147 return data 2148 2149 def GetTypeName(self, row, col): 2150 try: 2151 if self.data[row][col] is None: return None 2152 return self.dataTypes[col] 2153 except (TypeError,IndexError): 2154 return None 2155 2156 def GetValue(self, row, col): 2157 try: 2158 if self.data[row][col] is None: return "" 2159 return self.data[row][col] 2160 except IndexError: 2161 return None 2162 2163 def InsertRows(self, pos, rows): 2164 for row in range(rows): 2165 self.data.insert(pos,[]) 2166 pos += 1 2167 2168 def IsEmptyCell(self,row,col): 2169 try: 2170 return not self.data[row][col] 2171 except IndexError: 2172 return True 2173 2174 def OnKeyPress(self, event): 2175 dellist = self.GetSelectedRows() 2176 if event.GetKeyCode() == wx.WXK_DELETE and dellist: 2177 grid = self.GetView() 2178 for i in dellist: grid.DeleteRow(i) 2179 2180 def SetColLabelValue(self, col, label): 2181 numcols = self.GetNumberCols() 2182 if col > numcols-1: 2183 self.colLabels.append(label) 2184 else: 2185 self.colLabels[col]=label 2186 2187 def SetData(self,data): 2188 for row in range(len(data)): 2189 self.SetRowValues(row,data[row]) 2190 2191 def SetRowLabelValue(self, row, label): 2192 self.rowLabels[row]=label 2193 2194 def SetRowValues(self,row,data): 2195 self.data[row] = data 2196 2197 def SetValue(self, row, col, value): 2198 def innerSetValue(row, col, value): 2199 try: 2200 self.data[row][col] = value 2201 except TypeError: 2202 return 2203 except IndexError: 2204 print row,col,value 2205 # add a new row 2206 if row > self.GetNumberRows(): 2207 self.data.append([''] * self.GetNumberCols()) 2208 elif col > self.GetNumberCols(): 2209 for row in range(self.GetNumberRows): 2210 self.data[row].append('') 2211 print self.data 2212 self.data[row][col] = value 2213 innerSetValue(row, col, value) 2214 2215 ################################################################################ 2216 ##### Notebook 2217 ################################################################################ 2218 1347 ##### Notebook Tree Item editor 1348 ################################################################################ 2219 1349 def UpdateNotebook(G2frame,data): 2220 1350 '''Called when the data tree notebook entry is selected. Allows for … … 2240 1370 2241 1371 ################################################################################ 2242 ##### Controls 1372 ##### Controls Tree Item editor 2243 1373 ################################################################################ 2244 2245 1374 def UpdateControls(G2frame,data): 2246 1375 '''Edit overall GSAS-II controls in main Controls data tree entry … … 2602 1731 'No columns selected in table. Click on column labels to select fields for rename.') 2603 1732 return 2604 dlg = MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames)1733 dlg = G2G.MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames) 2605 1734 if dlg.Show(): 2606 1735 newNames = dlg.GetValues() … … 2760 1889 'Ask the user to select a pseudo var expression to delete' 2761 1890 choices = Controls['SeqPseudoVars'].keys() 2762 selected = ItemSelector(1891 selected = G2G.ItemSelector( 2763 1892 choices,G2frame.dataFrame, 2764 1893 multiple=True, … … 2777 1906 selected = 0 2778 1907 else: 2779 selected = ItemSelector(1908 selected = G2G.ItemSelector( 2780 1909 choices,G2frame.dataFrame, 2781 1910 multiple=False, … … 3015 2144 'Ask the user to select function to delete' 3016 2145 txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] 3017 selected = ItemSelector(2146 selected = G2G.ItemSelector( 3018 2147 txtlst,G2frame.dataFrame, 3019 2148 multiple=True, … … 3031 2160 selected = 0 3032 2161 else: 3033 selected = ItemSelector(2162 selected = G2G.ItemSelector( 3034 2163 txtlst,G2frame.dataFrame, 3035 2164 multiple=False, … … 3083 2212 selected = 0 3084 2213 else: 3085 selected = ItemSelector(2214 selected = G2G.ItemSelector( 3086 2215 txtlst,G2frame.dataFrame, 3087 2216 multiple=False, … … 3132 2261 var = colLabels[col] 3133 2262 lbl = variableLabels.get(var,G2obj.fmtVarDescr(var)) 3134 dlg = SingleStringDialog(G2frame.dataFrame,'Set variable label',2263 dlg = G2G.SingleStringDialog(G2frame.dataFrame,'Set variable label', 3135 2264 'Set a new name for variable '+var,lbl,size=(400,-1)) 3136 2265 if dlg.Show(): … … 3473 2602 depVarDict.update({var:val for var,val in data[name].get('newCellDict',{}).values()}) 3474 2603 3475 G2frame.dataDisplay = G SGrid(parent=G2frame.dataFrame)3476 G2frame.SeqTable = Table(2604 G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame) 2605 G2frame.SeqTable = G2G.Table( 3477 2606 [list(c) for c in zip(*colList)], # convert from columns to rows 3478 2607 colLabels=colLabels,rowLabels=histNames,types=Types) … … 4054 3183 G2frame.dataFrame.SetMenuBar(menu) 4055 3184 4056 def HorizontalLine(sizer,parent):4057 '''Draws a horizontal line as wide as the window.4058 This shows up on the Mac as a very thin line, no matter what I do4059 '''4060 line = wx.StaticLine(parent,-1, size=(-1,3), style=wx.LI_HORIZONTAL)4061 sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10)4062 4063 3185 def HowDidIgetHere(): 4064 3186 '''Show a traceback with calls that brought us to the current location. -
trunk/GSASIIimgGUI.py
r1770 r1831 1278 1278 max=100.,OnLeave=Replot,nDig=[8,2]) 1279 1279 littleSizer.Add(spotDiameter,0,WACV) 1280 spotDelete = G2 gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',1280 spotDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1281 1281 locationcode='Delete+Points+'+str(i), 1282 1282 handler=onDeleteMask) … … 1301 1301 min=0.001,max=1.,OnLeave=Replot,nDig=[8,3]) 1302 1302 littleSizer.Add(ringThick,0,WACV) 1303 ringDelete = G2 gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',1303 ringDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1304 1304 locationcode='Delete+Rings+'+str(i), 1305 1305 handler=onDeleteMask) … … 1331 1331 min=0.001,max=20.,OnLeave=Replot,nDig=[8,3]) 1332 1332 littleSizer.Add(arcThick,0,WACV) 1333 arcDelete = G2 gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',1333 arcDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1334 1334 locationcode='Delete+Arcs+'+str(i), 1335 1335 handler=onDeleteMask) … … 1349 1349 polyText = wx.ComboBox(G2frame.dataDisplay,value=polyList[0],choices=polyList,style=wx.CB_READONLY) 1350 1350 littleSizer.Add(polyText,0,WACV) 1351 polyDelete = G2 gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',1351 polyDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1352 1352 locationcode='Delete+Polygons+'+str(i), 1353 1353 handler=onDeleteMask) … … 1365 1365 frameText = wx.ComboBox(G2frame.dataDisplay,value=frameList[0],choices=frameList,style=wx.CB_READONLY) 1366 1366 littleSizer.Add(frameText,0,WACV) 1367 frameDelete = G2 gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',1367 frameDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1368 1368 locationcode='Delete+Frame', 1369 1369 handler=onDeleteFrame) … … 1515 1515 ifany = False 1516 1516 Names = [' ','Sample phi','Sample z','Sample load'] 1517 dlg = G2 gd.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',1517 dlg = G2G.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:', 1518 1518 'Select columns',Comments,Names,np.array(newItems).T) 1519 1519 try: -
trunk/GSASIIphsGUI.py
r1830 r1831 1050 1050 mainSizer.Add((5,5),0) 1051 1051 mainSizer.Add(ElemSizer()) 1052 G2 gd.HorizontalLine(mainSizer,General)1052 G2G.HorizontalLine(mainSizer,General) 1053 1053 1054 1054 if generalData['Type'] in ['modulated','magnetic',]: … … 1057 1057 G2frame.dataFrame.GeneralCalc.Enable(G2gd.wxID_4DCHARGEFLIP,True) 1058 1058 mainSizer.Add(ModulatedSizer(generalData['Type'])) 1059 G2 gd.HorizontalLine(mainSizer,General)1059 G2G.HorizontalLine(mainSizer,General) 1060 1060 else: 1061 1061 G2frame.dataFrame.GeneralCalc.Enable(G2gd.wxID_SINGLEMCSA,True) … … 1064 1064 1065 1065 mainSizer.Add(PawleySizer()) 1066 G2 gd.HorizontalLine(mainSizer,General)1066 G2G.HorizontalLine(mainSizer,General) 1067 1067 1068 1068 mainSizer.Add(MapSizer()) 1069 G2 gd.HorizontalLine(mainSizer,General)1069 G2G.HorizontalLine(mainSizer,General) 1070 1070 1071 1071 mainSizer.Add(FlipSizer()) 1072 1072 if generalData['Type'] in ['nuclear','macromolecular']: 1073 G2 gd.HorizontalLine(mainSizer,General)1073 G2G.HorizontalLine(mainSizer,General) 1074 1074 mainSizer.Add(MCSASizer()) 1075 1075 G2frame.dataFrame.SetStatusText('') … … 1375 1375 table.append(atom) 1376 1376 rowLabels.append(str(i)) 1377 atomTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1377 atomTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1378 1378 Atoms.SetTable(atomTable, True) 1379 1379 Atoms.frm = -1 … … 1387 1387 attr = wx.grid.GridCellAttr() 1388 1388 attr.IncRef() #fix from Jim Hester 1389 attr.SetEditor(G2 gd.GridFractionEditor(Atoms))1389 attr.SetEditor(G2G.GridFractionEditor(Atoms)) 1390 1390 for c in range(colX,colX+3): 1391 1391 attr = wx.grid.GridCellAttr() 1392 1392 attr.IncRef() #fix from Jim Hester 1393 attr.SetEditor(G2 gd.GridFractionEditor(Atoms))1393 attr.SetEditor(G2G.GridFractionEditor(Atoms)) 1394 1394 Atoms.SetColAttr(c, attr) 1395 1395 for i in range(colU11-1,colU11+6): … … 1729 1729 limits = [0.,0.25] 1730 1730 val = 0.01 1731 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new value for '+parm,val,limits)1731 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new value for '+parm,val,limits) 1732 1732 if dlg.ShowModal() == wx.ID_OK: 1733 1733 parm = dlg.GetValue() … … 1741 1741 limits = [-1.,1.] 1742 1742 val = 0. 1743 dlg = G2 gd.SingleFloatDialog(G2frame,'Atom shift','Enter shift for '+parm,val,limits)1743 dlg = G2G.SingleFloatDialog(G2frame,'Atom shift','Enter shift for '+parm,val,limits) 1744 1744 if dlg.ShowModal() == wx.ID_OK: 1745 1745 parm = dlg.GetValue() … … 2292 2292 uij = atom[cia+2:cia+8] 2293 2293 for SS in ['SS1',]: #future SS2 & SS3 - I doubt it! 2294 G2 gd.HorizontalLine(mainSizer,waveData)2294 G2G.HorizontalLine(mainSizer,waveData) 2295 2295 mainSizer.Add(AtomSizer(SS,atom)) 2296 2296 for Stype in ['Sfrac','Spos','Sadp','Smag']: … … 2641 2641 rowLabels.append(str(i)) 2642 2642 2643 atomTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)2643 atomTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 2644 2644 drawAtoms.SetTable(atomTable, True) 2645 2645 drawAtoms.SetMargins(0,0) … … 5130 5130 Types = [wg.GRID_VALUE_BOOL,wg.GRID_VALUE_BOOL,wg.GRID_VALUE_FLOAT+':10,4', 5131 5131 wg.GRID_VALUE_FLOAT+':10,4',]+maxVary*[wg.GRID_VALUE_FLOAT+':10,5',] 5132 resultsTable = G2 gd.Table(resultVals,rowLabels=rowLabels,colLabels=colLabels,types=Types)5133 resultsGrid = G2 gd.GSGrid(G2frame.MCSA)5132 resultsTable = G2G.Table(resultVals,rowLabels=rowLabels,colLabels=colLabels,types=Types) 5133 resultsGrid = G2G.GSGrid(G2frame.MCSA) 5134 5134 resultsGrid.SetTable(resultsTable, True) 5135 5135 resultsGrid.Bind(wg.EVT_GRID_CELL_LEFT_CLICK, OnCellChange) … … 5180 5180 mainSizer.Add(Rsizer) 5181 5181 Xsize = max(Rsizer.GetMinSize()[0],Xsize) 5182 G2 gd.HorizontalLine(mainSizer,G2frame.MCSA)5182 G2G.HorizontalLine(mainSizer,G2frame.MCSA) 5183 5183 5184 5184 if not data['MCSA']['Results']: … … 5419 5419 2*[wg.GRID_VALUE_FLOAT+':10,2',] 5420 5420 pos = [5,6] 5421 PawleyTable = G2 gd.Table(PawleyPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types)5421 PawleyTable = G2G.Table(PawleyPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types) 5422 5422 G2frame.PawleyRefl.SetTable(PawleyTable, True) 5423 5423 G2frame.PawleyRefl.Bind(wx.EVT_KEY_DOWN, KeyEditPawleyGrid) … … 5614 5614 colLabels = ['mag','x','y','z','dzero','dcent'] 5615 5615 Types = 6*[wg.GRID_VALUE_FLOAT+':10,4',] 5616 G2frame.MapPeaksTable = G2 gd.Table(mapPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types)5616 G2frame.MapPeaksTable = G2G.Table(mapPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types) 5617 5617 MapPeaks.SetTable(G2frame.MapPeaksTable, True) 5618 5618 MapPeaks.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect) … … 6147 6147 G2frame.dataFrame.SetLabel('Phase Data for '+PhaseName) 6148 6148 G2frame.dataFrame.CreateStatusBar() 6149 G2frame.dataDisplay = G2 gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())6149 G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize()) 6150 6150 G2frame.dataDisplay.gridList = [] # list of all grids in notebook 6151 6151 Pages = [] … … 6158 6158 G2frame.dataDisplay.AddPage(DData,'Data') 6159 6159 Pages.append('Data') 6160 Atoms = G2 gd.GSGrid(G2frame.dataDisplay)6160 Atoms = G2G.GSGrid(G2frame.dataDisplay) 6161 6161 G2frame.dataDisplay.gridList.append(Atoms) 6162 6162 G2frame.dataDisplay.AddPage(Atoms,'Atoms') … … 6169 6169 G2frame.dataDisplay.AddPage(drawOptions,'Draw Options') 6170 6170 Pages.append('Draw Options') 6171 drawAtoms = G2 gd.GSGrid(G2frame.dataDisplay)6171 drawAtoms = G2G.GSGrid(G2frame.dataDisplay) 6172 6172 G2frame.dataDisplay.gridList.append(drawAtoms) 6173 6173 G2frame.dataDisplay.AddPage(drawAtoms,'Draw Atoms') … … 6176 6176 G2frame.dataDisplay.AddPage(RigidBodies,'RB Models') 6177 6177 Pages.append('RB Models') 6178 MapPeaks = G2 gd.GSGrid(G2frame.dataDisplay)6178 MapPeaks = G2G.GSGrid(G2frame.dataDisplay) 6179 6179 G2frame.dataDisplay.gridList.append(MapPeaks) 6180 6180 G2frame.dataDisplay.AddPage(MapPeaks,'Map peaks') … … 6187 6187 G2frame.dataDisplay.AddPage(Texture,'Texture') 6188 6188 Pages.append('Texture') 6189 G2frame.PawleyRefl = G2 gd.GSGrid(G2frame.dataDisplay)6189 G2frame.PawleyRefl = G2G.GSGrid(G2frame.dataDisplay) 6190 6190 G2frame.dataDisplay.gridList.append(G2frame.PawleyRefl) 6191 6191 G2frame.dataDisplay.AddPage(G2frame.PawleyRefl,'Pawley reflections') -
trunk/GSASIIplot.py
r1815 r1831 3248 3248 Draw() 3249 3249 elif event.key == 't': 3250 dlg = G2 gd.MultiStringDialog(G2frame,'Set titles & labels',[' Title ',' x-Label ',' y-Label '],3250 dlg = G2G.MultiStringDialog(G2frame,'Set titles & labels',[' Title ',' x-Label ',' y-Label '], 3251 3251 [Title,xLabel,yLabel]) 3252 3252 if dlg.Show(): -
trunk/GSASIIpwdGUI.py
r1827 r1831 704 704 data['peaks'] = X 705 705 G2frame.PatternTree.SetItemPyData(G2frame.PickId,data) 706 G2frame.PeakTable = G2 gd.Table(data['peaks'],rowLabels=rowLabels,colLabels=colLabels,types=Types)706 G2frame.PeakTable = G2G.Table(data['peaks'],rowLabels=rowLabels,colLabels=colLabels,types=Types) 707 707 G2frame.dataFrame.SetLabel('Peak List') 708 G2frame.dataDisplay = G2 gd.GSGrid(parent=G2frame.dataFrame)708 G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame) 709 709 G2frame.dataDisplay.SetTable(G2frame.PeakTable, True) 710 710 setBackgroundColors() … … 914 914 wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_BOOL, 915 915 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 916 debyeTable = G2 gd.Table(data[1]['debyeTerms'],rowLabels=rowLabels,colLabels=colLabels,types=Types)917 debyeGrid = G2 gd.GSGrid(parent=G2frame.dataDisplay)916 debyeTable = G2G.Table(data[1]['debyeTerms'],rowLabels=rowLabels,colLabels=colLabels,types=Types) 917 debyeGrid = G2G.GSGrid(parent=G2frame.dataDisplay) 918 918 debyeGrid.SetTable(debyeTable, True) 919 919 debyeGrid.Bind(wx.EVT_KEY_DOWN, KeyEditPeakGrid) … … 974 974 wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_BOOL, 975 975 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 976 peaksTable = G2 gd.Table(data[1]['peaksList'],rowLabels=rowLabels,colLabels=colLabels,types=Types)977 peaksGrid = G2 gd.GSGrid(parent=G2frame.dataDisplay)976 peaksTable = G2G.Table(data[1]['peaksList'],rowLabels=rowLabels,colLabels=colLabels,types=Types) 977 peaksGrid = G2G.GSGrid(parent=G2frame.dataDisplay) 978 978 peaksGrid.SetTable(peaksTable, True) 979 979 peaksGrid.Bind(wx.EVT_KEY_DOWN, KeyEditPeakGrid) … … 1071 1071 rowLabels.append('exclude') 1072 1072 Types = 2*[wg.GRID_VALUE_FLOAT+':12,5',] 1073 G2frame.LimitsTable = G2 gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types)1073 G2frame.LimitsTable = G2G.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1074 1074 G2frame.dataFrame.SetLabel('Limits') 1075 1075 G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.LimitMenu) … … 1078 1078 G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2gd.wxID_LIMITCOPY) 1079 1079 G2frame.Bind(wx.EVT_MENU,OnAddExcl,id=G2gd.wxID_ADDEXCLREGION) 1080 G2frame.dataDisplay = G2 gd.GSGrid(parent=G2frame.dataFrame)1080 G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame) 1081 1081 G2frame.dataDisplay.SetTable(G2frame.LimitsTable, True) 1082 1082 G2frame.dataDisplay.SetCellStyle(0,0,VERY_LIGHT_GREY,True) … … 1717 1717 freeNames[Controls[name]] = name 1718 1718 Names.append(Controls[name]) 1719 dlg = G2 gd.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',1719 dlg = G2G.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:', 1720 1720 'Select columns',Comments,Names,np.array(newItems).T) 1721 1721 try: … … 2023 2023 else: 2024 2024 choices = ['Debye-Scherrer','Bragg-Brentano',] 2025 histoType = G2 gd.G2ChoiceButton(G2frame.dataDisplay,choices,2025 histoType = G2G.G2ChoiceButton(G2frame.dataDisplay,choices, 2026 2026 strLoc=data,strKey='Type', 2027 2027 onChoice=OnHistoChange) … … 2216 2216 4*[wg.GRID_VALUE_LONG,]+2*[wg.GRID_VALUE_FLOAT+':10,5',] 2217 2217 G2frame.PatternTree.SetItemPyData(IndexId,data) 2218 G2frame.IndexPeaksTable = G2 gd.Table(data[0],rowLabels=rowLabels,colLabels=colLabels,types=Types)2218 G2frame.IndexPeaksTable = G2G.Table(data[0],rowLabels=rowLabels,colLabels=colLabels,types=Types) 2219 2219 G2frame.dataFrame.SetLabel('Index Peak List') 2220 G2frame.dataDisplay = G2 gd.GSGrid(parent=G2frame.dataFrame)2220 G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame) 2221 2221 G2frame.dataDisplay.SetTable(G2frame.IndexPeaksTable, True) 2222 2222 XY = [] … … 2906 2906 hkl.insert(4,G2lat.Dsp2pos(Inst,hkl[3])+controls[1]) 2907 2907 table.append(row) 2908 UnitCellsTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)2909 gridDisplay = G2 gd.GSGrid(G2frame.dataDisplay)2908 UnitCellsTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 2909 gridDisplay = G2G.GSGrid(G2frame.dataDisplay) 2910 2910 gridDisplay.SetTable(UnitCellsTable, True) 2911 2911 G2frame.dataFrame.CopyCell.Enable(True) … … 2983 2983 2984 2984 def MakeReflectionTable(phaseName): 2985 '''Returns a wx.grid table (G2 gd.Table) containing a list of all reflections2985 '''Returns a wx.grid table (G2G.Table) containing a list of all reflections 2986 2986 for a phase. 2987 2987 ''' … … 3037 3037 if Super: 3038 3038 colLabels.insert(3,'M') 3039 return G2 gd.Table(refs,rowLabels=rowLabels,colLabels=colLabels,types=Types)3039 return G2G.Table(refs,rowLabels=rowLabels,colLabels=colLabels,types=Types) 3040 3040 3041 3041 def ShowReflTable(phaseName): … … 3143 3143 G2frame.dataFrame.SelectPhase.Enable(False) 3144 3144 3145 G2frame.dataDisplay = G2 gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())3145 G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize()) 3146 3146 G2frame.refTable = {} 3147 3147 for tabnum,phase in enumerate(phases): 3148 G2frame.refTable[phase] = G2 gd.GSGrid(parent=G2frame.dataDisplay)3148 G2frame.refTable[phase] = G2G.GSGrid(parent=G2frame.dataDisplay) 3149 3149 G2frame.dataDisplay.AddPage(G2frame.refTable[phase],phase) 3150 3150 if phaseName not in G2frame.refTable: … … 3365 3365 0,WACV) 3366 3366 for name in data['Substances']: 3367 G2 gd.HorizontalLine(substSizer,G2frame.dataDisplay)3367 G2G.HorizontalLine(substSizer,G2frame.dataDisplay) 3368 3368 substSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Data for '+name+':'), 3369 3369 0,WACV) … … 4030 4030 partSizer.Add(topSizer,0,) 4031 4031 for ilev,level in enumerate(data['Particle']['Levels']): 4032 G2 gd.HorizontalLine(partSizer,G2frame.dataDisplay)4032 G2G.HorizontalLine(partSizer,G2frame.dataDisplay) 4033 4033 topLevel = wx.BoxSizer(wx.HORIZONTAL) 4034 4034 topLevel.Add(wx.StaticText(G2frame.dataDisplay,label=' Model component %d: '%(ilev)),0,WACV) … … 4117 4117 topSizer.Add(esdScale,0,WACV) 4118 4118 mainSizer.Add(topSizer) 4119 G2 gd.HorizontalLine(mainSizer,G2frame.dataDisplay)4119 G2G.HorizontalLine(mainSizer,G2frame.dataDisplay) 4120 4120 if 'Size' in data['Current']: 4121 4121 if 'MaxEnt' in data['Size']['Method']: … … 4126 4126 elif 'Particle' in data['Current']: 4127 4127 mainSizer.Add(PartSizer(),1,wx.ALIGN_LEFT|wx.EXPAND) 4128 G2 gd.HorizontalLine(mainSizer,G2frame.dataDisplay)4128 G2G.HorizontalLine(mainSizer,G2frame.dataDisplay) 4129 4129 backSizer = wx.BoxSizer(wx.HORIZONTAL) 4130 4130 backSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Background:'),0,WACV) -
trunk/GSASIIrestrGUI.py
r1638 r1831 29 29 import GSASIIplot as G2plt 30 30 import GSASIIdata as G2data 31 import GSASIIctrls as G2G 31 32 32 33 VERY_LIGHT_GREY = wx.Colour(235,235,235) … … 224 225 if len(Lists['origin']) and len(Lists['target']): 225 226 bond = 1.54 226 dlg = G2 gd.SingleFloatDialog(G2frame,'Distance','Enter restraint distance for bond',bond,[0.01,4.],'%.4f')227 dlg = G2G.SingleFloatDialog(G2frame,'Distance','Enter restraint distance for bond',bond,[0.01,4.],'%.4f') 227 228 if dlg.ShowModal() == wx.ID_OK: 228 229 bond = dlg.GetValue() … … 334 335 if len(Lists['B-atom']): 335 336 value = 109.54 336 dlg = G2 gd.SingleFloatDialog(G2frame,'Angle','Enter restraint angle ',value,[30.,180.],'%.2f')337 dlg = G2G.SingleFloatDialog(G2frame,'Angle','Enter restraint angle ',value,[30.,180.],'%.2f') 337 338 if dlg.ShowModal() == wx.ID_OK: 338 339 value = dlg.GetValue() … … 722 723 if len(ids) > 2: 723 724 value = 1.0 724 dlg = G2 gd.SingleFloatDialog(G2frame,'Angle','Enter unit cell sum ',value,[-1.e6,1.e6],'%.2f')725 dlg = G2G.SingleFloatDialog(G2frame,'Angle','Enter unit cell sum ',value,[-1.e6,1.e6],'%.2f') 725 726 if dlg.ShowModal() == wx.ID_OK: 726 727 value = dlg.GetValue() … … 836 837 Bonds.ClearSelection() 837 838 val = bondList[rows[0]][2] 838 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new value for bond',val,[0.,5.],'%.4f')839 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new value for bond',val,[0.,5.],'%.4f') 839 840 if dlg.ShowModal() == wx.ID_OK: 840 841 parm = dlg.GetValue() … … 850 851 Bonds.ClearSelection() 851 852 val = bondList[rows[0]][3] 852 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new esd for bond',val,[0.,1.],'%.4f')853 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for bond',val,[0.,1.],'%.4f') 853 854 if dlg.ShowModal() == wx.ID_OK: 854 855 parm = dlg.GetValue() … … 918 919 for ibad in bad: 919 920 del bondList[ibad] 920 bondTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)921 Bonds = G2 gd.GSGrid(BondRestr)921 bondTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 922 Bonds = G2G.GSGrid(BondRestr) 922 923 Bonds.SetTable(bondTable, True) 923 924 Bonds.AutoSizeColumns(False) … … 966 967 Angles.ClearSelection() 967 968 val = angleList[rows[0]][2] 968 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new value for angle',val,[0.,360.],'%.2f')969 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new value for angle',val,[0.,360.],'%.2f') 969 970 if dlg.ShowModal() == wx.ID_OK: 970 971 parm = dlg.GetValue() … … 980 981 Angles.ClearSelection() 981 982 val = angleList[rows[0]][3] 982 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new esd for angle',val,[0.,5.],'%.2f')983 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for angle',val,[0.,5.],'%.2f') 983 984 if dlg.ShowModal() == wx.ID_OK: 984 985 parm = dlg.GetValue() … … 1047 1048 for ibad in bad: 1048 1049 del angleList[ibad] 1049 angleTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1050 Angles = G2 gd.GSGrid(AngleRestr)1050 angleTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1051 Angles = G2G.GSGrid(AngleRestr) 1051 1052 Angles.SetTable(angleTable, True) 1052 1053 Angles.AutoSizeColumns(False) … … 1100 1101 Planes.ClearSelection() 1101 1102 val = planeList[rows[0]][3] 1102 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new esd for plane',val,[0.,5.],'%.2f')1103 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for plane',val,[0.,5.],'%.2f') 1103 1104 if dlg.ShowModal() == wx.ID_OK: 1104 1105 parm = dlg.GetValue() … … 1172 1173 for ibad in bad: 1173 1174 del planeList[ibad] 1174 planeTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1175 Planes = G2 gd.GSGrid(PlaneRestr)1175 planeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1176 Planes = G2G.GSGrid(PlaneRestr) 1176 1177 Planes.SetTable(planeTable, True) 1177 1178 Planes.AutoSizeColumns(False) … … 1231 1232 Volumes.ClearSelection() 1232 1233 val = volumeList[rows[0]][2] 1233 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new value for chiral volume',val,[0.,360.],'%.2f')1234 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new value for chiral volume',val,[0.,360.],'%.2f') 1234 1235 if dlg.ShowModal() == wx.ID_OK: 1235 1236 parm = dlg.GetValue() … … 1245 1246 Volumes.ClearSelection() 1246 1247 val = volumeList[rows[0]][3] 1247 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new esd for chiral volume',val,[0.,5.],'%.2f')1248 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for chiral volume',val,[0.,5.],'%.2f') 1248 1249 if dlg.ShowModal() == wx.ID_OK: 1249 1250 parm = dlg.GetValue() … … 1302 1303 for ibad in bad: 1303 1304 del volumeList[ibad] 1304 volumeTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1305 Volumes = G2 gd.GSGrid(ChiralRestr)1305 volumeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1306 Volumes = G2G.GSGrid(ChiralRestr) 1306 1307 Volumes.SetTable(volumeTable, True) 1307 1308 Volumes.AutoSizeColumns(False) … … 1360 1361 Torsions.ClearSelection() 1361 1362 val = torsionList[rows[0]][4] 1362 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new esd for torsion restraints',val,[0.,5.],'%.2f')1363 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for torsion restraints',val,[0.,5.],'%.2f') 1363 1364 if dlg.ShowModal() == wx.ID_OK: 1364 1365 parm = dlg.GetValue() … … 1403 1404 for ibad in bad: 1404 1405 del torsionList[ibad] 1405 torsionTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1406 TorsionRestr.Torsions = G2 gd.GSGrid(TorsionRestr)1406 torsionTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1407 TorsionRestr.Torsions = G2G.GSGrid(TorsionRestr) 1407 1408 TorsionRestr.Torsions.SetTable(torsionTable, True) 1408 1409 TorsionRestr.Torsions.AutoSizeColumns(False) … … 1429 1430 rowLabels.append(item) 1430 1431 table.append(coeffDict[item]) 1431 coeffTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1432 Coeff = G2 gd.GSGrid(TorsionRestr)1432 coeffTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1433 Coeff = G2G.GSGrid(TorsionRestr) 1433 1434 Coeff.SetTable(coeffTable, True) 1434 1435 Coeff.AutoSizeColumns(False) … … 1479 1480 Ramas.ClearSelection() 1480 1481 val = ramaList[rows[0]][4] 1481 dlg = G2 gd.SingleFloatDialog(G2frame,'New value','Enter new esd for energy',val,[0.,5.],'%.2f')1482 dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for energy',val,[0.,5.],'%.2f') 1482 1483 if dlg.ShowModal() == wx.ID_OK: 1483 1484 parm = dlg.GetValue() … … 1523 1524 for ibad in bad: 1524 1525 del ramaList[ibad] 1525 ramaTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1526 RamaRestr.Ramas = G2 gd.GSGrid(RamaRestr)1526 ramaTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1527 RamaRestr.Ramas = G2G.GSGrid(RamaRestr) 1527 1528 RamaRestr.Ramas.SetTable(ramaTable, True) 1528 1529 RamaRestr.Ramas.AutoSizeColumns(False) … … 1552 1553 rowLabels.append(item+' term:'+str(i)) 1553 1554 table.append(term) 1554 coeffTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1555 Coeff = G2 gd.GSGrid(RamaRestr)1555 coeffTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1556 Coeff = G2G.GSGrid(RamaRestr) 1556 1557 Coeff.SetTable(coeffTable, True) 1557 1558 Coeff.AutoSizeColumns(False) … … 1610 1611 return 1611 1612 ChemComps.ClearSelection() 1612 dlg = G2 gd.SingleFloatDialog(G2frame,'New value',1613 dlg = G2G.SingleFloatDialog(G2frame,'New value', 1613 1614 'Enter new value for restraint multiplier',1.0,[-1.e6,1.e6],'%.2f') 1614 1615 if dlg.ShowModal() == wx.ID_OK: … … 1659 1660 for ibad in bad: 1660 1661 del chemcompList[ibad] 1661 chemcompTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1662 ChemComps = G2 gd.GSGrid(ChemCompRestr)1662 chemcompTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1663 ChemComps = G2G.GSGrid(ChemCompRestr) 1663 1664 ChemComps.SetTable(chemcompTable, True) 1664 1665 ChemComps.AutoSizeColumns(False) … … 1752 1753 table.append(['%d %d %d'%(hkl[0],hkl[1],hkl[2]),grid,esd1,ifesd2,esd2]) 1753 1754 rowLabels.append(str(i)) 1754 textureTable = G2 gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)1755 Textures = G2 gd.GSGrid(TextureRestr)1755 textureTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 1756 Textures = G2G.GSGrid(TextureRestr) 1756 1757 Textures.SetTable(textureTable, True) 1757 1758 Textures.AutoSizeColumns(False) … … 1866 1867 G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddAARestraint, id=G2gd.wxID_AARESTRAINTADD) 1867 1868 G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlotAARestraint, id=G2gd.wxID_AARESTRAINTPLOT) 1868 G2frame.dataDisplay = G2 gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())1869 G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize()) 1869 1870 1870 1871 # clear menu and menu pointers -
trunk/exports/G2export_CIF.py
r1782 r1831 47 47 import GSASIIphsGUI as G2pg 48 48 import GSASIIstrMain as G2stMn 49 import GSASIIctrls as G2G 49 50 50 51 DEBUG = False #True to skip printing of reflection/powder profile lists … … 1277 1278 'dialog to edit the CIF author info' 1278 1279 'Edit the CIF author name' 1279 dlg = G2 gd.SingleStringDialog(self.G2frame,1280 dlg = G2G.SingleStringDialog(self.G2frame, 1280 1281 'Get CIF Author', 1281 1282 'Provide CIF Author name (Last, First)', … … 1350 1351 cpnl = wxscroll.ScrolledPanel(self.cifdefs,size=(300,300)) 1351 1352 cbox = wx.BoxSizer(wx.VERTICAL) 1352 G2 gd.HorizontalLine(cbox,cpnl)1353 G2G.HorizontalLine(cbox,cpnl) 1353 1354 cbox.Add( 1354 1355 CIFtemplateSelect(self.cifdefs, … … 1359 1360 0,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL) 1360 1361 for phasenam in sorted(self.Phases.keys()): 1361 G2 gd.HorizontalLine(cbox,cpnl)1362 G2G.HorizontalLine(cbox,cpnl) 1362 1363 title = 'Phase '+phasenam 1363 1364 phasedict = self.Phases[phasenam] # pointer to current phase info … … 1382 1383 cbox.Add((-1,2)) 1383 1384 for i in sorted(self.powderDict.keys()): 1384 G2 gd.HorizontalLine(cbox,cpnl)1385 G2G.HorizontalLine(cbox,cpnl) 1385 1386 hist = self.powderDict[i] 1386 1387 histblk = self.Histograms[hist] … … 1394 1395 0,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL) 1395 1396 for i in sorted(self.xtalDict.keys()): 1396 G2 gd.HorizontalLine(cbox,cpnl)1397 G2G.HorizontalLine(cbox,cpnl) 1397 1398 hist = self.xtalDict[i] 1398 1399 histblk = self.Histograms[hist] … … 1524 1525 hbox.Add(but) 1525 1526 but.SetValue(True) 1526 G2 gd.HorizontalLine(vbox,dlg)1527 G2G.HorizontalLine(vbox,dlg) 1527 1528 1528 1529 cpnl = wxscroll.ScrolledPanel(dlg,size=(400,300)) … … 1571 1572 ) 1572 1573 cbox.Add(dbox) 1573 G2 gd.HorizontalLine(cbox,cpnl)1574 G2G.HorizontalLine(cbox,cpnl) 1574 1575 cpnl.SetSizer(cbox) 1575 1576 cpnl.SetAutoLayout(1) … … 2215 2216 cpnl = EditCIFpanel(self,cifblk,loopstructure,CIFdic,OKbuttons,size=(300,300)) 2216 2217 vbox.Add(cpnl, 1, wx.ALIGN_LEFT|wx.ALL|wx.EXPAND, 0) 2217 G2 gd.HorizontalLine(vbox,self)2218 G2G.HorizontalLine(vbox,self) 2218 2219 vbox.Add(self.helptxt, 0, wx.EXPAND|wx.ALL, 5) 2219 G2 gd.HorizontalLine(vbox,self)2220 G2G.HorizontalLine(vbox,self) 2220 2221 btnsizer = wx.BoxSizer(wx.HORIZONTAL) 2221 2222 btn = wx.Button(self, wx.ID_CANCEL) … … 2439 2440 for i in self.cifdic[dataname].get('_enumeration_detail',values): 2440 2441 choices.append(G2IO.trim(i)) 2441 ent = G2 gd.EnumSelector(self, dct, item, choices, values, size=(200, -1))2442 ent = G2G.EnumSelector(self, dct, item, choices, values, size=(200, -1)) 2442 2443 return ent 2443 2444 if self.cifdic[dataname].get('_type') == 'numb':
Note: See TracChangeset
for help on using the changeset viewer.