Changeset 1831


Ignore:
Timestamp:
May 1, 2015 6:38:23 PM (7 years ago)
Author:
toby
Message:

move remaining generic controls to G2ctrls

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1829 r1831  
    644644        notOK = True
    645645        while notOK:
    646             result = G2gd.ItemSelector(TextList,self,header,header='Add histogram(s)',multiple=True)
     646            result = G2G.ItemSelector(TextList,self,header,header='Add histogram(s)',multiple=True)
    647647            if not result: return
    648648            # check that selected single crystal histograms are not already in use!
     
    804804        for Name in newHistList:
    805805            header += '\n  '+str(Name)
    806         result = G2gd.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)
    807807        if not result: return
    808808        # connect new phases to histograms
     
    14041404            header += '\n  '+str(Name)
    14051405
    1406         result = G2gd.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)
    14071407        if not result: return
    14081408        # connect new phases to histograms
     
    15691569        if not phaseNameList: return # no phases yet, nothing to do
    15701570        header = 'Select phase(s) to add the new\npowder simulation (dummy) dataset to:'
    1571         result = G2gd.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)
    15721572        if not result: return
    15731573        # connect new phases to histograms
  • trunk/GSASIIIO.py

    r1814 r1831  
    19251925            elif self.multiple:
    19261926                choices = sorted(self.Phases.keys())
    1927                 phasenum = G2gd.ItemSelector(choices,self.G2frame,multiple=True)
     1927                phasenum = G2G.ItemSelector(choices,self.G2frame,multiple=True)
    19281928                if phasenum is None: return True
    19291929                self.phasenam = [choices[i] for i in phasenum]
     
    19321932            else:
    19331933                choices = sorted(self.Phases.keys())
    1934                 phasenum = G2gd.ItemSelector(choices,self.G2frame)
     1934                phasenum = G2G.ItemSelector(choices,self.G2frame)
    19351935                if phasenum is None: return True
    19361936                self.phasenam = [choices[phasenum]]
     
    19461946            elif self.multiple:
    19471947                choices = sorted(self.xtalDict.values())
    1948                 hnum = G2gd.ItemSelector(choices,self.G2frame,multiple=True)
     1948                hnum = G2G.ItemSelector(choices,self.G2frame,multiple=True)
    19491949                if not hnum: return True
    19501950                self.histnam = [choices[i] for i in hnum]
     
    19521952            else:
    19531953                choices = sorted(self.xtalDict.values())
    1954                 hnum = G2gd.ItemSelector(choices,self.G2frame)
     1954                hnum = G2G.ItemSelector(choices,self.G2frame)
    19551955                if hnum is None: return True
    19561956                self.histnam = [choices[hnum]]
     
    19661966            elif self.multiple:
    19671967                choices = sorted(self.powderDict.values())
    1968                 hnum = G2gd.ItemSelector(choices,self.G2frame,multiple=True)
     1968                hnum = G2G.ItemSelector(choices,self.G2frame,multiple=True)
    19691969                if not hnum: return True
    19701970                self.histnam = [choices[i] for i in hnum]
     
    19721972            else:
    19731973                choices = sorted(self.powderDict.values())
    1974                 hnum = G2gd.ItemSelector(choices,self.G2frame)
     1974                hnum = G2G.ItemSelector(choices,self.G2frame)
    19751975                if hnum is None: return True
    19761976                self.histnam = [choices[hnum]]
     
    19861986            else:
    19871987                choices = sorted(self.Histograms.keys())
    1988                 hnum = G2gd.ItemSelector(choices,self.G2frame,multiple=self.multiple)
     1988                hnum = G2G.ItemSelector(choices,self.G2frame,multiple=self.multiple)
    19891989                if self.multiple:
    19901990                    if not hnum: return True
     
    20192019                self.phasenam = mapPhases
    20202020            else:
    2021                 phasenum = G2gd.ItemSelector(choices,self.G2frame,multiple=self.multiple)
     2021                phasenum = G2G.ItemSelector(choices,self.G2frame,multiple=self.multiple)
    20222022                if self.multiple:
    20232023                    if not phasenum: return True
  • trunk/GSASIIconstrGUI.py

    r1827 r1831  
    998998        G2frame.dataFrame.Bind(wx.EVT_MENU, RaisePage,id=id)
    999999
    1000     G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame)
     1000    G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame)
    10011001    # note that order of pages is hard-coded in RaisePage
    10021002    PhaseConstr = wx.ScrolledWindow(G2frame.dataDisplay)
     
    14701470                table.append(list(xyz)+[rbData['rbTypes'][ivec],]+list(XYZ[ivec]))
    14711471                rowLabels.append(str(ivec))
    1472             vecTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1473             vecGrid = G2gd.GSGrid(VectorRBDisplay)
     1472            vecTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1473            vecGrid = G2G.GSGrid(VectorRBDisplay)
    14741474            vecGrid.SetTable(vecTable, True)
    14751475            vecGrid.Bind(wg.EVT_GRID_CELL_CHANGE, ChangeCell)
     
    14771477                vecGrid.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, TypeSelect)
    14781478            attr = wx.grid.GridCellAttr()
    1479             attr.SetEditor(G2gd.GridFractionEditor(vecGrid))
     1479            attr.SetEditor(G2G.GridFractionEditor(vecGrid))
    14801480            for c in range(3):
    14811481                vecGrid.SetColAttr(c, attr)
     
    16381638                table.append([rbData['atNames'][ivec],]+[rbData['rbTypes'][ivec],]+list(xyz))
    16391639                rowLabels.append(str(ivec))
    1640             vecTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1641             vecGrid = G2gd.GSGrid(ResidueRBDisplay)
     1640            vecTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1641            vecGrid = G2G.GSGrid(ResidueRBDisplay)
    16421642            Indx[vecGrid.GetId()] = rbId
    16431643            resList.append(vecGrid)
     
    16471647            vecGrid.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect)
    16481648            attr = wx.grid.GridCellAttr()
    1649             attr.SetEditor(G2gd.GridFractionEditor(vecGrid))
     1649            attr.SetEditor(G2G.GridFractionEditor(vecGrid))
    16501650            for c in range(3):
    16511651                vecGrid.SetColAttr(c, attr)
     
    18261826    SetStatusLine('')
    18271827
    1828     G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
     1828    G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
    18291829
    18301830    VectorRB = wx.ScrolledWindow(G2frame.dataDisplay)
  • trunk/GSASIIctrls.py

    r1814 r1831  
    1818'''
    1919import wx
    20 # import wx.grid as wg
     20import wx.grid as wg
    2121# import wx.wizard as wz
    22 # import wx.aui
     22import wx.aui
    2323import wx.lib.scrolledpanel as wxscroll
    2424import time
     
    766766
    767767################################################################################
    768 #### Edit a large number of values
     768def 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################################################################################
     776class 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################################################################################
     801class 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################################################################################
     860class 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
     924class 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
    769952################################################################################
    770953def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[],
     
    788971        return False
    789972
     973################################################################################
    790974class ScrolledMultiEditor(wx.Dialog):
    791975    '''Define a window for editing a potentially large number of dict- or
     
    10111195            self.OKbtn.Disable()
    10121196
    1013 ################################################################################
    1014 #### Multichoice Dialog with set all, toggle & filter options
    1015 ################################################################################
     1197###############################################  Multichoice Dialog with set all, toggle & filter options
    10161198class G2MultiChoiceDialog(wx.Dialog):
    10171199    '''A dialog similar to MultiChoiceDialog except that buttons are
     
    13911573        dlg.Destroy()
    13921574
    1393 ################################################################################
    1394 #### Single choice Dialog with filter options
    1395 ################################################################################
     1575################################################################        Single choice Dialog with filter options
    13961576class G2SingleChoiceDialog(wx.Dialog):
    13971577    '''A dialog similar to wx.SingleChoiceDialog except that a filter can be
     
    15081688
    15091689################################################################################
    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.
     1690def G2MessageBox(parent,msg,title='Error'):
     1691    '''Simple code to display a error or warning message
    15271692    '''
    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   
    15401697################################################################################
    15411698class PickTwoDialog(wx.Dialog):
     
    16061763
    16071764################################################################################
    1608 #### Column-order selection
     1765class 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
    16091824################################################################################
    1610 
     1825class 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################################################################################
     1874class 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################################################################################
     1935class 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################################################################################
     2069def 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
    16112115def GetItemOrder(parent,keylist,vallookup,posdict):
    16122116    '''Creates a panel where items can be ordered into columns
     
    17492253
    17502254################################################################################
     2255#####  Customized Grid Support
     2256################################################################################           
     2257class 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################################################################################           
     2331class 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################################################################################
     2469class 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################################################################################           
     2567class 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################################################################################
    17512632#### Help support routines
    17522633################################################################################
     
    21172998        msg1 = msg.replace('\n ','\n')
    21182999    return msg.replace('\n\t','\n')
    2119 
    2120 def G2MessageBox(parent,msg,title='Error'):
    2121     '''Simple code to display a error or warning message
    2122     '''
    2123     dlg = wx.MessageDialog(parent,StripIndents(msg), title, wx.OK)
    2124     dlg.ShowModal()
    2125     dlg.Destroy()
    21263000       
    21273001################################################################################
     
    22043078        'Get the version number in the dialog'
    22053079        return self.spin.GetValue()
     3080
    22063081################################################################################
    22073082#### Display Help information
     
    22463121        else:
    22473122            webbrowser.open(pfx+helplink, new=0, autoraise=True)
     3123
    22483124def ShowWebPage(URL,frame):
    22493125    '''Called to show a tutorial web page.
     
    22773153        else:
    22783154            webbrowser.open(pfx+URL, new=0, autoraise=True)
     3155
    22793156################################################################################
    2280 #### Tutorials selector
     3157#### Tutorials support
    22813158################################################################################
    22823159G2BaseURL = "https://subversion.xray.aps.anl.gov/pyGSAS"
  • trunk/GSASIIgrid.py

    r1822 r1831  
    1212--------------------------------
    1313
    14 Note that a number of routines here should be moved to GSASIIctrls eventually, such as
    15 G2LoggedButton, EnumSelector, G2ChoiceButton, SingleFloatDialog, SingleStringDialog,
    16 MultiStringDialog, G2ColumnIDDialog, ItemSelector, GridFractionEditor
    17 
    18 Probably SGMessageBox, SymOpDialog, DisAglDialog, too.
    19 
    2014'''
    2115import wx
    2216import wx.grid as wg
    23 import wx.wizard as wz
    24 import wx.aui
     17#import wx.wizard as wz
     18#import wx.aui
    2519import wx.lib.scrolledpanel as wxscroll
    2620import time
     
    156150
    157151VERY_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
    158170################################################################################
    159171#### GSAS-II class definitions
     
    206218        self.ShowModal()
    207219        return
    208 
    209 class G2LoggedButton(wx.Button):
    210     '''A version of wx.Button that creates logging events. Bindings are saved
    211     in the object, and are looked up rather than directly set with a bind.
    212     An index to these buttons is saved as log.ButtonBindingLookup
    213     :param wx.Panel parent: parent widget
    214     :param int id: Id for button
    215     :param str label: label for button
    216     :param str locationcode: a label used internally to uniquely indentify the button
    217     :param function handler: a routine to call when the button is pressed
    218     '''
    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 = label
    223         self.handler = handler
    224         self.locationcode = locationcode
    225         key = locationcode + '+' + label # hash code to find button
    226         self.Bind(wx.EVT_BUTTON,self.onPress)
    227         log.ButtonBindingLookup[key] = self
    228     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 list
    237     of choices, but sets a dict (list) entry to the corresponding
    238     entry from the input list of values.
    239 
    240     :param wx.Panel parent: the parent to the :class:`~wxpython.ComboBox` (usually a
    241       frame or panel)
    242     :param dict dct: a dict (or list) to contain the value set
    243       for the :class:`~wxpython.ComboBox`.
    244     :param item: the dict key (or list index) where ``dct[item]`` will
    245       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 value
    247       does not match an entry in :data:`values`, the first value
    248       in :data:`choices` is used as the default, but ``dct[item]`` is
    249       not changed.   
    250     :param list choices: a list of choices to be displayed to the
    251       user such as
    252       ::
    253      
    254       ["default","option 1","option 2",]
    255 
    256       Note that these options will correspond to the entries in
    257       :data:`values` (if specified) item by item.
    258     :param list values: a list of values that correspond to
    259       the options in :data:`choices`, such as
    260       ::
    261      
    262       [0,1,2]
    263      
    264       The default for :data:`values` is to use the same list as
    265       specified for :data:`choices`.
    266     :param (other): additional keyword arguments accepted by
    267       :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 = choices
    272         if dct[item] in values:
    273             i = values.index(dct[item])
    274         else:
    275             i = 0
    276         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 = choices
    282         self.values = values
    283         self.dct = dct
    284         self.item = item
    285         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 dictionary
    288         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] # unknown
    292 
    293 ################################################################################
    294 ################################################################################
    295 class G2ChoiceButton(wx.Choice):
    296     '''A customized version of a wx.Choice that automatically initializes
    297     the control to match a supplied value and saves the choice directly
    298     into an array or list. Optionally a function can be called each time a
    299     choice is selected. The widget can be used with an array item that is set to
    300     to the choice by number (``indLoc[indKey]``) or by string value
    301     (``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 be
    305       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 be
    308       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 be
    310       edited by the Choice button. If indLoc is not None then this
    311       must be specified and the ``indLoc[indKey]`` will be set. If the value
    312       for ``indLoc[indKey]`` is not None, it should be an integer in
    313       range(len(choiceList)). The Choice button will be initialized to the
    314       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 to
    316       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 value
    318       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 = choiceList
    325         self.indLoc = indLoc
    326         self.indKey = indKey
    327         self.strLoc = strLoc
    328         self.strKey = strKey
    329         self.onChoice = None
    330         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                 pass
    344         self.Bind(wx.EVT_CHOICE, self._OnChoice)
    345         #if self.strLoc is not None: # make sure strLoc gets initialized
    346         #    self._OnChoice(None) # note that onChoice will not be called
    347         self.onChoice = onChoice
    348     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()
    357220
    358221################################################################################
     
    577440        self.Draw(self.data)
    578441               
    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 = limits
    586         self.value = value
    587         self.prompt = prompt
    588         self.format = format
    589         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 ValueError
    598             except ValueError:
    599                 val = self.value
    600             self.value = val
    601             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.value
    627        
    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 user
    641    
    642     :param wx.Frame parent: name of parent frame
    643     :param str title: title string for dialog
    644     :param str prompt: string to tell use what they are inputting
    645     :param str value: default input value, if any
    646     '''
    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 = value
    652         self.prompt = prompt
    653         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 it
    673         :returns: True if the user pressed OK; False if the User pressed Cancel
    674         '''
    675         if self.ShowModal() == wx.ID_OK:
    676             self.value = self.valItem.GetValue()
    677             return True
    678         else:
    679             return False
    680 
    681     def GetValue(self):
    682         '''Use this method to get the value entered by the user
    683         :returns: string entered by user
    684         '''
    685         return self.value
    686 
    687 ################################################################################
    688 class MultiStringDialog(wx.Dialog):
    689     '''Dialog to obtain a multi string values from user
    690    
    691     :param wx.Frame parent: name of parent frame
    692     :param str title: title string for dialog
    693     :param str prompts: strings to tell use what they are inputting
    694     :param str values: default input values, if any
    695     '''
    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 = values
    702         self.prompts = prompts
    703         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()] = prompt
    712             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 it
    735         :returns: True if the user pressed OK; False if the User pressed Cancel
    736         '''
    737         if self.ShowModal() == wx.ID_OK:
    738             return True
    739         else:
    740             return False
    741 
    742     def GetValues(self):
    743         '''Use this method to get the value entered by the user
    744         :returns: string entered by user
    745         '''
    746         return self.values
    747 
    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 frame
    754     :param str title: heading above list of choices
    755     :param str header: Title to place on window frame
    756     :param list ChoiceList: a list of possible choices for the columns
    757     :param list ColumnData: lists of column data to be matched with ChoiceList
    758     :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 may
    761       be included such as size [which defaults to `(320,310)`] and
    762       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`` controls
    764       the presence of the eponymous buttons in the dialog.
    765     :returns: the name of the created dialog
    766    
    767     '''
    768 
    769     def __init__(self,parent, title, header,Comments,ChoiceList, ColumnData,
    770                  monoFont=False, **kw):
    771 
    772         def OnOk(sevent):
    773             OK = True
    774             selCols = []
    775             for col in self.sel:
    776                 item = col.GetValue()
    777                 if item != ' ' and item in selCols:
    778                     OK = False
    779                     break
    780                 else:
    781                     selCols.append(item)
    782             parent = self.GetParent()
    783             if not OK:
    784                 parent.ErrorDialog('Duplicate',item+' selected more than once')
    785                 return
    786             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                 return
    795             print 'Modify column',icol,' by', modify
    796             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 style
    802         options = {'size':(600,310), # default Frame keywords
    803                    '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 = ChoiceList
    808         self.ColumnData = ColumnData
    809         nCol = len(ColumnData)
    810         if options['style'] & wx.OK:
    811             useOK = True
    812             options['style'] ^= wx.OK
    813         else:
    814             useOK = False
    815         if options['style'] & wx.CANCEL:
    816             useCANCEL = True
    817             options['style'] ^= wx.CANCEL
    818         else:
    819             useCANCEL = False       
    820         # create the dialog frame
    821         wx.Dialog.__init__(self,parent,wx.ID_ANY,header,**options)
    822         panel = wxscroll.ScrolledPanel(self)
    823         # fill the dialog
    824         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 buttons
    854         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 here
    868         panel.SetSizer(Sizer)
    869         panel.SetAutoLayout(1)
    870         panel.SetupScrolling()
    871         Size = [450,375]
    872         panel.SetSize(Size)
    873         Size[0] += 25; Size[1]+= 25
    874         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.ColumnData
    882 
    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 choices
    890 
    891     :param list ChoiceList: a list of choices where one will be selected
    892     :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 offered
    897     :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 true
    900     '''
    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 None
    928     dlg.Destroy()
    929 
    930 ################################################################################
    931 class GridFractionEditor(wg.PyGridCellEditor):
    932     '''A grid cell editor class that allows entry of values as fractions as well
    933     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 = False
    961 
    962         self.nextval = self.startValue
    963         val = self._tc.GetValue().lower()
    964         if val != self.startValue:
    965             changed = True
    966             neg = False
    967             if '-' in val:
    968                 neg = True
    969             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.startValue
    985                 return None
    986            
    987             if oldVal is None: # this arg appears in 2.9+; before, we should go ahead & change the table
    988                 grid.GetTable().SetValue(row, col, val) # update the table
    989             # otherwise self.ApplyEdit gets called
    990 
    991         self.startValue = ''
    992         self._tc.SetValue('')
    993         return changed
    994    
    995     def ApplyEdit(self, row, col, grid):
    996         """ Called only in wx >= 2.9
    997         Save the value of the control into the grid if EndEdit() returns as True
    998         """
    999         grid.GetTable().SetValue(row, col, self.nextval) # update the table
    1000 
    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             return
    1017         if key > 255:
    1018             evt.Skip()
    1019             return
    1020         char = chr(key)
    1021         if char in '.+-/0123456789cosind()':
    1022             self._tc.WriteText(char)
    1023         else:
    1024             evt.Skip()
    1025 
    1026442################################################################################
    1027443class ShowLSParms(wx.Dialog):
     
    19271343        self.DestroyChildren()
    19281344                   
     1345
    19291346################################################################################
    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################################################################################                 
    22191349def UpdateNotebook(G2frame,data):
    22201350    '''Called when the data tree notebook entry is selected. Allows for
     
    22401370           
    22411371################################################################################
    2242 #####  Controls
     1372#####  Controls Tree Item editor
    22431373################################################################################           
    2244        
    22451374def UpdateControls(G2frame,data):
    22461375    '''Edit overall GSAS-II controls in main Controls data tree entry
     
    26021731                'No columns selected in table. Click on column labels to select fields for rename.')
    26031732            return
    2604         dlg = MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames)
     1733        dlg = G2G.MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames)
    26051734        if dlg.Show():
    26061735            newNames = dlg.GetValues()           
     
    27601889        'Ask the user to select a pseudo var expression to delete'
    27611890        choices = Controls['SeqPseudoVars'].keys()
    2762         selected = ItemSelector(
     1891        selected = G2G.ItemSelector(
    27631892            choices,G2frame.dataFrame,
    27641893            multiple=True,
     
    27771906            selected = 0
    27781907        else:
    2779             selected = ItemSelector(
     1908            selected = G2G.ItemSelector(
    27801909                choices,G2frame.dataFrame,
    27811910                multiple=False,
     
    30152144        'Ask the user to select function to delete'
    30162145        txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']]
    3017         selected = ItemSelector(
     2146        selected = G2G.ItemSelector(
    30182147            txtlst,G2frame.dataFrame,
    30192148            multiple=True,
     
    30312160            selected = 0
    30322161        else:
    3033             selected = ItemSelector(
     2162            selected = G2G.ItemSelector(
    30342163                txtlst,G2frame.dataFrame,
    30352164                multiple=False,
     
    30832212            selected = 0
    30842213        else:
    3085             selected = ItemSelector(
     2214            selected = G2G.ItemSelector(
    30862215                txtlst,G2frame.dataFrame,
    30872216                multiple=False,
     
    31322261        var = colLabels[col]
    31332262        lbl = variableLabels.get(var,G2obj.fmtVarDescr(var))
    3134         dlg = SingleStringDialog(G2frame.dataFrame,'Set variable label',
     2263        dlg = G2G.SingleStringDialog(G2frame.dataFrame,'Set variable label',
    31352264                                 'Set a new name for variable '+var,lbl,size=(400,-1))
    31362265        if dlg.Show():
     
    34732602    depVarDict.update({var:val for var,val in data[name].get('newCellDict',{}).values()})
    34742603
    3475     G2frame.dataDisplay = GSGrid(parent=G2frame.dataFrame)
    3476     G2frame.SeqTable = Table(
     2604    G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame)
     2605    G2frame.SeqTable = G2G.Table(
    34772606        [list(c) for c in zip(*colList)],     # convert from columns to rows
    34782607        colLabels=colLabels,rowLabels=histNames,types=Types)
     
    40543183            G2frame.dataFrame.SetMenuBar(menu)
    40553184
    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 do
    4059     '''
    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 
    40633185def HowDidIgetHere():
    40643186    '''Show a traceback with calls that brought us to the current location.
  • trunk/GSASIIimgGUI.py

    r1770 r1831  
    12781278                                           max=100.,OnLeave=Replot,nDig=[8,2])
    12791279                littleSizer.Add(spotDiameter,0,WACV)
    1280                 spotDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',
     1280                spotDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?',
    12811281                                            locationcode='Delete+Points+'+str(i),
    12821282                                            handler=onDeleteMask)
     
    13011301                                           min=0.001,max=1.,OnLeave=Replot,nDig=[8,3])
    13021302                littleSizer.Add(ringThick,0,WACV)
    1303                 ringDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',
     1303                ringDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?',
    13041304                                            locationcode='Delete+Rings+'+str(i),
    13051305                                            handler=onDeleteMask)
     
    13311331                                           min=0.001,max=20.,OnLeave=Replot,nDig=[8,3])
    13321332                littleSizer.Add(arcThick,0,WACV)
    1333                 arcDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',
     1333                arcDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?',
    13341334                                            locationcode='Delete+Arcs+'+str(i),
    13351335                                            handler=onDeleteMask)
     
    13491349                polyText = wx.ComboBox(G2frame.dataDisplay,value=polyList[0],choices=polyList,style=wx.CB_READONLY)
    13501350                littleSizer.Add(polyText,0,WACV)
    1351                 polyDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',
     1351                polyDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?',
    13521352                                            locationcode='Delete+Polygons+'+str(i),
    13531353                                            handler=onDeleteMask)
     
    13651365        frameText = wx.ComboBox(G2frame.dataDisplay,value=frameList[0],choices=frameList,style=wx.CB_READONLY)
    13661366        littleSizer.Add(frameText,0,WACV)
    1367         frameDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?',
     1367        frameDelete = G2G.G2LoggedButton(G2frame.dataDisplay,label='delete?',
    13681368                                            locationcode='Delete+Frame',
    13691369                                            handler=onDeleteFrame)
     
    15151515        ifany = False
    15161516        Names = [' ','Sample phi','Sample z','Sample load']
    1517         dlg = G2gd.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',
     1517        dlg = G2G.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',
    15181518            'Select columns',Comments,Names,np.array(newItems).T)
    15191519        try:
  • trunk/GSASIIphsGUI.py

    r1830 r1831  
    10501050            mainSizer.Add((5,5),0)           
    10511051            mainSizer.Add(ElemSizer())
    1052         G2gd.HorizontalLine(mainSizer,General)
     1052        G2G.HorizontalLine(mainSizer,General)
    10531053       
    10541054        if generalData['Type'] in ['modulated','magnetic',]:
     
    10571057            G2frame.dataFrame.GeneralCalc.Enable(G2gd.wxID_4DCHARGEFLIP,True)
    10581058            mainSizer.Add(ModulatedSizer(generalData['Type']))
    1059             G2gd.HorizontalLine(mainSizer,General)
     1059            G2G.HorizontalLine(mainSizer,General)
    10601060        else:
    10611061            G2frame.dataFrame.GeneralCalc.Enable(G2gd.wxID_SINGLEMCSA,True)
     
    10641064
    10651065        mainSizer.Add(PawleySizer())
    1066         G2gd.HorizontalLine(mainSizer,General)
     1066        G2G.HorizontalLine(mainSizer,General)
    10671067       
    10681068        mainSizer.Add(MapSizer())
    1069         G2gd.HorizontalLine(mainSizer,General)
     1069        G2G.HorizontalLine(mainSizer,General)
    10701070       
    10711071        mainSizer.Add(FlipSizer())
    10721072        if generalData['Type'] in ['nuclear','macromolecular']:
    1073             G2gd.HorizontalLine(mainSizer,General)
     1073            G2G.HorizontalLine(mainSizer,General)
    10741074            mainSizer.Add(MCSASizer())
    10751075        G2frame.dataFrame.SetStatusText('')
     
    13751375                table.append(atom)
    13761376                rowLabels.append(str(i))
    1377             atomTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1377            atomTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    13781378            Atoms.SetTable(atomTable, True)
    13791379            Atoms.frm = -1           
     
    13871387            attr = wx.grid.GridCellAttr()
    13881388            attr.IncRef()               #fix from Jim Hester
    1389             attr.SetEditor(G2gd.GridFractionEditor(Atoms))
     1389            attr.SetEditor(G2G.GridFractionEditor(Atoms))
    13901390            for c in range(colX,colX+3):
    13911391                attr = wx.grid.GridCellAttr()
    13921392                attr.IncRef()               #fix from Jim Hester
    1393                 attr.SetEditor(G2gd.GridFractionEditor(Atoms))
     1393                attr.SetEditor(G2G.GridFractionEditor(Atoms))
    13941394                Atoms.SetColAttr(c, attr)
    13951395            for i in range(colU11-1,colU11+6):
     
    17291729                    limits = [0.,0.25]
    17301730                    val = 0.01
    1731                 dlg = G2gd.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)
    17321732                if dlg.ShowModal() == wx.ID_OK:
    17331733                    parm = dlg.GetValue()
     
    17411741                limits = [-1.,1.]
    17421742                val = 0.
    1743                 dlg = G2gd.SingleFloatDialog(G2frame,'Atom shift','Enter shift for '+parm,val,limits)
     1743                dlg = G2G.SingleFloatDialog(G2frame,'Atom shift','Enter shift for '+parm,val,limits)
    17441744                if dlg.ShowModal() == wx.ID_OK:
    17451745                    parm = dlg.GetValue()
     
    22922292                uij = atom[cia+2:cia+8]
    22932293                for SS in ['SS1',]:  #future SS2 & SS3 - I doubt it!
    2294                     G2gd.HorizontalLine(mainSizer,waveData)
     2294                    G2G.HorizontalLine(mainSizer,waveData)
    22952295                    mainSizer.Add(AtomSizer(SS,atom))
    22962296                    for Stype in ['Sfrac','Spos','Sadp','Smag']:
     
    26412641            rowLabels.append(str(i))
    26422642
    2643         atomTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     2643        atomTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    26442644        drawAtoms.SetTable(atomTable, True)
    26452645        drawAtoms.SetMargins(0,0)
     
    51305130            Types = [wg.GRID_VALUE_BOOL,wg.GRID_VALUE_BOOL,wg.GRID_VALUE_FLOAT+':10,4',
    51315131                wg.GRID_VALUE_FLOAT+':10,4',]+maxVary*[wg.GRID_VALUE_FLOAT+':10,5',]
    5132             resultsTable = G2gd.Table(resultVals,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    5133             resultsGrid = G2gd.GSGrid(G2frame.MCSA)
     5132            resultsTable = G2G.Table(resultVals,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     5133            resultsGrid = G2G.GSGrid(G2frame.MCSA)
    51345134            resultsGrid.SetTable(resultsTable, True)
    51355135            resultsGrid.Bind(wg.EVT_GRID_CELL_LEFT_CLICK, OnCellChange)
     
    51805180                    mainSizer.Add(Rsizer)
    51815181                    Xsize = max(Rsizer.GetMinSize()[0],Xsize)
    5182                 G2gd.HorizontalLine(mainSizer,G2frame.MCSA)
     5182                G2G.HorizontalLine(mainSizer,G2frame.MCSA)
    51835183               
    51845184        if not data['MCSA']['Results']:
     
    54195419                    2*[wg.GRID_VALUE_FLOAT+':10,2',]
    54205420                pos = [5,6]
    5421             PawleyTable = G2gd.Table(PawleyPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     5421            PawleyTable = G2G.Table(PawleyPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    54225422            G2frame.PawleyRefl.SetTable(PawleyTable, True)
    54235423            G2frame.PawleyRefl.Bind(wx.EVT_KEY_DOWN, KeyEditPawleyGrid)                 
     
    56145614            colLabels = ['mag','x','y','z','dzero','dcent']
    56155615            Types = 6*[wg.GRID_VALUE_FLOAT+':10,4',]
    5616             G2frame.MapPeaksTable = G2gd.Table(mapPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     5616            G2frame.MapPeaksTable = G2G.Table(mapPeaks,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    56175617            MapPeaks.SetTable(G2frame.MapPeaksTable, True)
    56185618            MapPeaks.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect)
     
    61476147    G2frame.dataFrame.SetLabel('Phase Data for '+PhaseName)
    61486148    G2frame.dataFrame.CreateStatusBar()
    6149     G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
     6149    G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
    61506150    G2frame.dataDisplay.gridList = [] # list of all grids in notebook
    61516151    Pages = []   
     
    61586158    G2frame.dataDisplay.AddPage(DData,'Data')
    61596159    Pages.append('Data')
    6160     Atoms = G2gd.GSGrid(G2frame.dataDisplay)
     6160    Atoms = G2G.GSGrid(G2frame.dataDisplay)
    61616161    G2frame.dataDisplay.gridList.append(Atoms)
    61626162    G2frame.dataDisplay.AddPage(Atoms,'Atoms')
     
    61696169    G2frame.dataDisplay.AddPage(drawOptions,'Draw Options')
    61706170    Pages.append('Draw Options')
    6171     drawAtoms = G2gd.GSGrid(G2frame.dataDisplay)
     6171    drawAtoms = G2G.GSGrid(G2frame.dataDisplay)
    61726172    G2frame.dataDisplay.gridList.append(drawAtoms)
    61736173    G2frame.dataDisplay.AddPage(drawAtoms,'Draw Atoms')
     
    61766176    G2frame.dataDisplay.AddPage(RigidBodies,'RB Models')
    61776177    Pages.append('RB Models')
    6178     MapPeaks = G2gd.GSGrid(G2frame.dataDisplay)
     6178    MapPeaks = G2G.GSGrid(G2frame.dataDisplay)
    61796179    G2frame.dataDisplay.gridList.append(MapPeaks)   
    61806180    G2frame.dataDisplay.AddPage(MapPeaks,'Map peaks')
     
    61876187    G2frame.dataDisplay.AddPage(Texture,'Texture')
    61886188    Pages.append('Texture')
    6189     G2frame.PawleyRefl = G2gd.GSGrid(G2frame.dataDisplay)
     6189    G2frame.PawleyRefl = G2G.GSGrid(G2frame.dataDisplay)
    61906190    G2frame.dataDisplay.gridList.append(G2frame.PawleyRefl)
    61916191    G2frame.dataDisplay.AddPage(G2frame.PawleyRefl,'Pawley reflections')
  • trunk/GSASIIplot.py

    r1815 r1831  
    32483248            Draw()
    32493249        elif event.key == 't':
    3250             dlg = G2gd.MultiStringDialog(G2frame,'Set titles & labels',[' Title ',' x-Label ',' y-Label '],
     3250            dlg = G2G.MultiStringDialog(G2frame,'Set titles & labels',[' Title ',' x-Label ',' y-Label '],
    32513251                [Title,xLabel,yLabel])
    32523252            if dlg.Show():
  • trunk/GSASIIpwdGUI.py

    r1827 r1831  
    704704    data['peaks'] = X
    705705    G2frame.PatternTree.SetItemPyData(G2frame.PickId,data)
    706     G2frame.PeakTable = G2gd.Table(data['peaks'],rowLabels=rowLabels,colLabels=colLabels,types=Types)
     706    G2frame.PeakTable = G2G.Table(data['peaks'],rowLabels=rowLabels,colLabels=colLabels,types=Types)
    707707    G2frame.dataFrame.SetLabel('Peak List')
    708     G2frame.dataDisplay = G2gd.GSGrid(parent=G2frame.dataFrame)
     708    G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame)
    709709    G2frame.dataDisplay.SetTable(G2frame.PeakTable, True)
    710710    setBackgroundColors()                         
     
    914914            wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_BOOL,
    915915            wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL]
    916             debyeTable = G2gd.Table(data[1]['debyeTerms'],rowLabels=rowLabels,colLabels=colLabels,types=Types)
    917             debyeGrid = G2gd.GSGrid(parent=G2frame.dataDisplay)
     916            debyeTable = G2G.Table(data[1]['debyeTerms'],rowLabels=rowLabels,colLabels=colLabels,types=Types)
     917            debyeGrid = G2G.GSGrid(parent=G2frame.dataDisplay)
    918918            debyeGrid.SetTable(debyeTable, True)
    919919            debyeGrid.Bind(wx.EVT_KEY_DOWN, KeyEditPeakGrid)
     
    974974            wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_BOOL,
    975975            wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL]
    976             peaksTable = G2gd.Table(data[1]['peaksList'],rowLabels=rowLabels,colLabels=colLabels,types=Types)
    977             peaksGrid = G2gd.GSGrid(parent=G2frame.dataDisplay)
     976            peaksTable = G2G.Table(data[1]['peaksList'],rowLabels=rowLabels,colLabels=colLabels,types=Types)
     977            peaksGrid = G2G.GSGrid(parent=G2frame.dataDisplay)
    978978            peaksGrid.SetTable(peaksTable, True)
    979979            peaksGrid.Bind(wx.EVT_KEY_DOWN, KeyEditPeakGrid)
     
    10711071        rowLabels.append('exclude')
    10721072    Types = 2*[wg.GRID_VALUE_FLOAT+':12,5',]
    1073     G2frame.LimitsTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1073    G2frame.LimitsTable = G2G.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    10741074    G2frame.dataFrame.SetLabel('Limits')
    10751075    G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.LimitMenu)
     
    10781078    G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2gd.wxID_LIMITCOPY)
    10791079    G2frame.Bind(wx.EVT_MENU,OnAddExcl,id=G2gd.wxID_ADDEXCLREGION)   
    1080     G2frame.dataDisplay = G2gd.GSGrid(parent=G2frame.dataFrame)
     1080    G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame)
    10811081    G2frame.dataDisplay.SetTable(G2frame.LimitsTable, True)   
    10821082    G2frame.dataDisplay.SetCellStyle(0,0,VERY_LIGHT_GREY,True)
     
    17171717            freeNames[Controls[name]] = name
    17181718            Names.append(Controls[name])
    1719         dlg = G2gd.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',
     1719        dlg = G2G.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',
    17201720            'Select columns',Comments,Names,np.array(newItems).T)
    17211721        try:
     
    20232023        else:
    20242024            choices = ['Debye-Scherrer','Bragg-Brentano',]
    2025         histoType = G2gd.G2ChoiceButton(G2frame.dataDisplay,choices,
     2025        histoType = G2G.G2ChoiceButton(G2frame.dataDisplay,choices,
    20262026                    strLoc=data,strKey='Type',
    20272027                    onChoice=OnHistoChange)
     
    22162216            4*[wg.GRID_VALUE_LONG,]+2*[wg.GRID_VALUE_FLOAT+':10,5',]
    22172217    G2frame.PatternTree.SetItemPyData(IndexId,data)
    2218     G2frame.IndexPeaksTable = G2gd.Table(data[0],rowLabels=rowLabels,colLabels=colLabels,types=Types)
     2218    G2frame.IndexPeaksTable = G2G.Table(data[0],rowLabels=rowLabels,colLabels=colLabels,types=Types)
    22192219    G2frame.dataFrame.SetLabel('Index Peak List')
    2220     G2frame.dataDisplay = G2gd.GSGrid(parent=G2frame.dataFrame)               
     2220    G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame)               
    22212221    G2frame.dataDisplay.SetTable(G2frame.IndexPeaksTable, True)
    22222222    XY = []
     
    29062906                    hkl.insert(4,G2lat.Dsp2pos(Inst,hkl[3])+controls[1])
    29072907            table.append(row)
    2908         UnitCellsTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    2909         gridDisplay = G2gd.GSGrid(G2frame.dataDisplay)
     2908        UnitCellsTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     2909        gridDisplay = G2G.GSGrid(G2frame.dataDisplay)
    29102910        gridDisplay.SetTable(UnitCellsTable, True)
    29112911        G2frame.dataFrame.CopyCell.Enable(True)
     
    29832983       
    29842984    def MakeReflectionTable(phaseName):
    2985         '''Returns a wx.grid table (G2gd.Table) containing a list of all reflections
     2985        '''Returns a wx.grid table (G2G.Table) containing a list of all reflections
    29862986        for a phase.       
    29872987        '''
     
    30373037            if Super:
    30383038                colLabels.insert(3,'M')
    3039         return G2gd.Table(refs,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     3039        return G2G.Table(refs,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    30403040
    30413041    def ShowReflTable(phaseName):
     
    31433143        G2frame.dataFrame.SelectPhase.Enable(False)
    31443144           
    3145     G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
     3145    G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
    31463146    G2frame.refTable = {}
    31473147    for tabnum,phase in enumerate(phases):
    3148         G2frame.refTable[phase] = G2gd.GSGrid(parent=G2frame.dataDisplay)
     3148        G2frame.refTable[phase] = G2G.GSGrid(parent=G2frame.dataDisplay)
    31493149        G2frame.dataDisplay.AddPage(G2frame.refTable[phase],phase)
    31503150    if phaseName not in G2frame.refTable:
     
    33653365            0,WACV)
    33663366        for name in data['Substances']:
    3367             G2gd.HorizontalLine(substSizer,G2frame.dataDisplay)   
     3367            G2G.HorizontalLine(substSizer,G2frame.dataDisplay)   
    33683368            substSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Data for '+name+':'),
    33693369                0,WACV)
     
    40304030        partSizer.Add(topSizer,0,)
    40314031        for ilev,level in enumerate(data['Particle']['Levels']):
    4032             G2gd.HorizontalLine(partSizer,G2frame.dataDisplay)
     4032            G2G.HorizontalLine(partSizer,G2frame.dataDisplay)
    40334033            topLevel = wx.BoxSizer(wx.HORIZONTAL)
    40344034            topLevel.Add(wx.StaticText(G2frame.dataDisplay,label=' Model component %d: '%(ilev)),0,WACV)
     
    41174117    topSizer.Add(esdScale,0,WACV)
    41184118    mainSizer.Add(topSizer)
    4119     G2gd.HorizontalLine(mainSizer,G2frame.dataDisplay)
     4119    G2G.HorizontalLine(mainSizer,G2frame.dataDisplay)
    41204120    if 'Size' in data['Current']:
    41214121        if 'MaxEnt' in data['Size']['Method']:
     
    41264126    elif 'Particle' in data['Current']:
    41274127        mainSizer.Add(PartSizer(),1,wx.ALIGN_LEFT|wx.EXPAND)
    4128     G2gd.HorizontalLine(mainSizer,G2frame.dataDisplay)   
     4128    G2G.HorizontalLine(mainSizer,G2frame.dataDisplay)   
    41294129    backSizer = wx.BoxSizer(wx.HORIZONTAL)
    41304130    backSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Background:'),0,WACV)
  • trunk/GSASIIrestrGUI.py

    r1638 r1831  
    2929import GSASIIplot as G2plt
    3030import GSASIIdata as G2data
     31import GSASIIctrls as G2G
    3132
    3233VERY_LIGHT_GREY = wx.Colour(235,235,235)
     
    224225        if len(Lists['origin']) and len(Lists['target']):
    225226            bond = 1.54
    226             dlg = G2gd.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')
    227228            if dlg.ShowModal() == wx.ID_OK:
    228229                bond = dlg.GetValue()
     
    334335        if len(Lists['B-atom']):
    335336            value = 109.54
    336             dlg = G2gd.SingleFloatDialog(G2frame,'Angle','Enter restraint angle ',value,[30.,180.],'%.2f')
     337            dlg = G2G.SingleFloatDialog(G2frame,'Angle','Enter restraint angle ',value,[30.,180.],'%.2f')
    337338            if dlg.ShowModal() == wx.ID_OK:
    338339                value = dlg.GetValue()
     
    722723            if len(ids) > 2:
    723724                value = 1.0
    724                 dlg = G2gd.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')
    725726                if dlg.ShowModal() == wx.ID_OK:
    726727                    value = dlg.GetValue()               
     
    836837            Bonds.ClearSelection()
    837838            val = bondList[rows[0]][2]
    838             dlg = G2gd.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')
    839840            if dlg.ShowModal() == wx.ID_OK:
    840841                parm = dlg.GetValue()
     
    850851            Bonds.ClearSelection()
    851852            val = bondList[rows[0]][3]
    852             dlg = G2gd.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')
    853854            if dlg.ShowModal() == wx.ID_OK:
    854855                parm = dlg.GetValue()
     
    918919                for ibad in bad:
    919920                    del bondList[ibad]
    920             bondTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    921             Bonds = G2gd.GSGrid(BondRestr)
     921            bondTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     922            Bonds = G2G.GSGrid(BondRestr)
    922923            Bonds.SetTable(bondTable, True)
    923924            Bonds.AutoSizeColumns(False)
     
    966967            Angles.ClearSelection()
    967968            val = angleList[rows[0]][2]
    968             dlg = G2gd.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')
    969970            if dlg.ShowModal() == wx.ID_OK:
    970971                parm = dlg.GetValue()
     
    980981            Angles.ClearSelection()
    981982            val = angleList[rows[0]][3]
    982             dlg = G2gd.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')
    983984            if dlg.ShowModal() == wx.ID_OK:
    984985                parm = dlg.GetValue()
     
    10471048                for ibad in bad:
    10481049                    del angleList[ibad]
    1049             angleTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1050             Angles = G2gd.GSGrid(AngleRestr)
     1050            angleTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1051            Angles = G2G.GSGrid(AngleRestr)
    10511052            Angles.SetTable(angleTable, True)
    10521053            Angles.AutoSizeColumns(False)
     
    11001101            Planes.ClearSelection()
    11011102            val = planeList[rows[0]][3]
    1102             dlg = G2gd.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')
    11031104            if dlg.ShowModal() == wx.ID_OK:
    11041105                parm = dlg.GetValue()
     
    11721173                for ibad in bad:
    11731174                    del planeList[ibad]
    1174             planeTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1175             Planes = G2gd.GSGrid(PlaneRestr)
     1175            planeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1176            Planes = G2G.GSGrid(PlaneRestr)
    11761177            Planes.SetTable(planeTable, True)
    11771178            Planes.AutoSizeColumns(False)
     
    12311232            Volumes.ClearSelection()
    12321233            val = volumeList[rows[0]][2]
    1233             dlg = G2gd.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')
    12341235            if dlg.ShowModal() == wx.ID_OK:
    12351236                parm = dlg.GetValue()
     
    12451246            Volumes.ClearSelection()
    12461247            val = volumeList[rows[0]][3]
    1247             dlg = G2gd.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')
    12481249            if dlg.ShowModal() == wx.ID_OK:
    12491250                parm = dlg.GetValue()
     
    13021303                for ibad in bad:
    13031304                    del volumeList[ibad]
    1304             volumeTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1305             Volumes = G2gd.GSGrid(ChiralRestr)
     1305            volumeTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1306            Volumes = G2G.GSGrid(ChiralRestr)
    13061307            Volumes.SetTable(volumeTable, True)
    13071308            Volumes.AutoSizeColumns(False)
     
    13601361            Torsions.ClearSelection()
    13611362            val = torsionList[rows[0]][4]
    1362             dlg = G2gd.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')
    13631364            if dlg.ShowModal() == wx.ID_OK:
    13641365                parm = dlg.GetValue()
     
    14031404                for ibad in bad:
    14041405                    del torsionList[ibad]
    1405             torsionTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1406             TorsionRestr.Torsions = G2gd.GSGrid(TorsionRestr)
     1406            torsionTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1407            TorsionRestr.Torsions = G2G.GSGrid(TorsionRestr)
    14071408            TorsionRestr.Torsions.SetTable(torsionTable, True)
    14081409            TorsionRestr.Torsions.AutoSizeColumns(False)
     
    14291430                rowLabels.append(item)
    14301431                table.append(coeffDict[item])
    1431             coeffTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1432             Coeff = G2gd.GSGrid(TorsionRestr)
     1432            coeffTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1433            Coeff = G2G.GSGrid(TorsionRestr)
    14331434            Coeff.SetTable(coeffTable, True)
    14341435            Coeff.AutoSizeColumns(False)
     
    14791480            Ramas.ClearSelection()
    14801481            val = ramaList[rows[0]][4]
    1481             dlg = G2gd.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')
    14821483            if dlg.ShowModal() == wx.ID_OK:
    14831484                parm = dlg.GetValue()
     
    15231524                for ibad in bad:
    15241525                    del ramaList[ibad]
    1525             ramaTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1526             RamaRestr.Ramas = G2gd.GSGrid(RamaRestr)
     1526            ramaTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1527            RamaRestr.Ramas = G2G.GSGrid(RamaRestr)
    15271528            RamaRestr.Ramas.SetTable(ramaTable, True)
    15281529            RamaRestr.Ramas.AutoSizeColumns(False)
     
    15521553                    rowLabels.append(item+' term:'+str(i))
    15531554                    table.append(term)
    1554             coeffTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1555             Coeff = G2gd.GSGrid(RamaRestr)
     1555            coeffTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1556            Coeff = G2G.GSGrid(RamaRestr)
    15561557            Coeff.SetTable(coeffTable, True)
    15571558            Coeff.AutoSizeColumns(False)
     
    16101611                return
    16111612            ChemComps.ClearSelection()
    1612             dlg = G2gd.SingleFloatDialog(G2frame,'New value',
     1613            dlg = G2G.SingleFloatDialog(G2frame,'New value',
    16131614                'Enter new value for restraint multiplier',1.0,[-1.e6,1.e6],'%.2f')
    16141615            if dlg.ShowModal() == wx.ID_OK:
     
    16591660                for ibad in bad:
    16601661                    del chemcompList[ibad]
    1661             chemcompTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1662             ChemComps = G2gd.GSGrid(ChemCompRestr)
     1662            chemcompTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1663            ChemComps = G2G.GSGrid(ChemCompRestr)
    16631664            ChemComps.SetTable(chemcompTable, True)
    16641665            ChemComps.AutoSizeColumns(False)
     
    17521753                table.append(['%d %d %d'%(hkl[0],hkl[1],hkl[2]),grid,esd1,ifesd2,esd2])
    17531754                rowLabels.append(str(i))
    1754             textureTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1755             Textures = G2gd.GSGrid(TextureRestr)
     1755            textureTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     1756            Textures = G2G.GSGrid(TextureRestr)
    17561757            Textures.SetTable(textureTable, True)
    17571758            Textures.AutoSizeColumns(False)
     
    18661867        G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddAARestraint, id=G2gd.wxID_AARESTRAINTADD)
    18671868        G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlotAARestraint, id=G2gd.wxID_AARESTRAINTPLOT)
    1868     G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
     1869    G2frame.dataDisplay = G2G.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize())
    18691870   
    18701871    # clear menu and menu pointers
  • trunk/exports/G2export_CIF.py

    r1782 r1831  
    4747import GSASIIphsGUI as G2pg
    4848import GSASIIstrMain as G2stMn
     49import GSASIIctrls as G2G
    4950
    5051DEBUG = False    #True to skip printing of reflection/powder profile lists
     
    12771278            'dialog to edit the CIF author info'
    12781279            'Edit the CIF author name'
    1279             dlg = G2gd.SingleStringDialog(self.G2frame,
     1280            dlg = G2G.SingleStringDialog(self.G2frame,
    12801281                                          'Get CIF Author',
    12811282                                          'Provide CIF Author name (Last, First)',
     
    13501351            cpnl = wxscroll.ScrolledPanel(self.cifdefs,size=(300,300))
    13511352            cbox = wx.BoxSizer(wx.VERTICAL)
    1352             G2gd.HorizontalLine(cbox,cpnl)         
     1353            G2G.HorizontalLine(cbox,cpnl)         
    13531354            cbox.Add(
    13541355                CIFtemplateSelect(self.cifdefs,
     
    13591360                0,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL)
    13601361            for phasenam in sorted(self.Phases.keys()):
    1361                 G2gd.HorizontalLine(cbox,cpnl)         
     1362                G2G.HorizontalLine(cbox,cpnl)         
    13621363                title = 'Phase '+phasenam
    13631364                phasedict = self.Phases[phasenam] # pointer to current phase info           
     
    13821383                cbox.Add((-1,2))
    13831384            for i in sorted(self.powderDict.keys()):
    1384                 G2gd.HorizontalLine(cbox,cpnl)         
     1385                G2G.HorizontalLine(cbox,cpnl)         
    13851386                hist = self.powderDict[i]
    13861387                histblk = self.Histograms[hist]
     
    13941395                    0,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL)
    13951396            for i in sorted(self.xtalDict.keys()):
    1396                 G2gd.HorizontalLine(cbox,cpnl)         
     1397                G2G.HorizontalLine(cbox,cpnl)         
    13971398                hist = self.xtalDict[i]
    13981399                histblk = self.Histograms[hist]
     
    15241525            hbox.Add(but)
    15251526            but.SetValue(True)
    1526             G2gd.HorizontalLine(vbox,dlg)         
     1527            G2G.HorizontalLine(vbox,dlg)         
    15271528           
    15281529            cpnl = wxscroll.ScrolledPanel(dlg,size=(400,300))
     
    15711572                                 )
    15721573                cbox.Add(dbox)
    1573                 G2gd.HorizontalLine(cbox,cpnl)         
     1574                G2G.HorizontalLine(cbox,cpnl)         
    15741575            cpnl.SetSizer(cbox)
    15751576            cpnl.SetAutoLayout(1)
     
    22152216        cpnl = EditCIFpanel(self,cifblk,loopstructure,CIFdic,OKbuttons,size=(300,300))
    22162217        vbox.Add(cpnl, 1, wx.ALIGN_LEFT|wx.ALL|wx.EXPAND, 0)
    2217         G2gd.HorizontalLine(vbox,self)
     2218        G2G.HorizontalLine(vbox,self)
    22182219        vbox.Add(self.helptxt, 0, wx.EXPAND|wx.ALL, 5)
    2219         G2gd.HorizontalLine(vbox,self)
     2220        G2G.HorizontalLine(vbox,self)
    22202221        btnsizer = wx.BoxSizer(wx.HORIZONTAL)
    22212222        btn = wx.Button(self, wx.ID_CANCEL)
     
    24392440                for i in self.cifdic[dataname].get('_enumeration_detail',values):
    24402441                    choices.append(G2IO.trim(i))
    2441                 ent = G2gd.EnumSelector(self, dct, item, choices, values, size=(200, -1))
     2442                ent = G2G.EnumSelector(self, dct, item, choices, values, size=(200, -1))
    24422443                return ent
    24432444            if self.cifdic[dataname].get('_type') == 'numb':
Note: See TracChangeset for help on using the changeset viewer.