Changeset 4911


Ignore:
Timestamp:
May 20, 2021 12:07:05 PM (2 years ago)
Author:
toby
Message:

implement european decimal (,) for grid fraction editor; use it for all columns in Atoms & Layersgrids; beginning of fullrmc edits

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4909 r4911  
    48094809        self.nextval = self.startValue
    48104810        val = self._tc.GetValue().lower().strip()
     4811        val = val.replace(',','.') # allow , for decimal
    48114812        if val != str(self.startValue):
    48124813            changed = True
     
    48554856    def OnChar(self, evt):
    48564857        key = evt.GetKeyCode()
    4857         if key < 32 or key >= 127:
     4858        if key < 32 or key >= 127: # outside printable ascii range; needed for backspace etc.
    48584859            evt.Skip()
    4859         elif chr(key).lower() in '.+-*/0123456789cosind()':
     4860        elif chr(key).lower() in '.+-*/0123456789cosind(),':
    48604861            evt.Skip()
    48614862        else:
  • trunk/GSASIIphsGUI.py

    r4900 r4911  
    34163416                   
    34173417        def Paint(Scroll=0):
    3418            
     3418            'Place atom info into the table'
    34193419            table = []
    34203420            rowLabels = []
     
    34423442#                Lande = generalData['Lande g']
    34433443#                AtInfo = dict(zip(atTypes,Lande))
    3444             attr = wx.grid.GridCellAttr()
    3445             attr.IncRef()               #fix from Jim Hester
    3446             attr.SetEditor(G2G.GridFractionEditor(Atoms))
    3447             for c in range(colX,colX+4):
     3444            # next 3 lines do not seem to do anything. Removed 5/20/21 BHT
     3445            # attr = wx.grid.GridCellAttr()
     3446            # attr.IncRef()               #fix from Jim Hester
     3447            # attr.SetEditor(G2G.GridFractionEditor(Atoms))
     3448            #
     3449            # loop over all cols in table, set cell editor for numerical items
     3450            for c,t in enumerate(Types):
     3451                if not t.startswith(wg.GRID_VALUE_FLOAT): continue
    34483452                attr = wx.grid.GridCellAttr()
    34493453                attr.IncRef()               #fix from Jim Hester
    34503454                attr.SetEditor(G2G.GridFractionEditor(Atoms))
     3455                if c in range(colU11-1,colU11+6):
     3456                    Atoms.SetColSize(c,50)           
     3457                    attr.SetBackgroundColour(VERY_LIGHT_GREY)
     3458                    attr.SetTextColour(VERY_LIGHT_GREY)
     3459                    attr.SetReadOnly(True)
    34513460                Atoms.SetColAttr(c, attr)
    3452             for i in range(colU11-1,colU11+6):
    3453                 Atoms.SetColSize(i,50)           
    3454                 attr = wx.grid.GridCellAttr()
    3455                 attr.IncRef()               #fix from Jim Hester
    3456                 attr.SetBackgroundColour(VERY_LIGHT_GREY)
    3457                 attr.SetTextColour(VERY_LIGHT_GREY)
    3458                 attr.SetReadOnly(True)
    3459                 Atoms.SetColAttr(i, attr)
    34603461            for row in range(Atoms.GetNumberRows()):    #this is slow for large numbers of atoms
    34613462                atId = atomData[row][colIA+8]
     
    47724773                Obj = event.GetEventObject()
    47734774                fil = Indx[Obj.GetId()]
     4775                G2frame.OnFileSave(event)
    47744776                dlg = wx.FileDialog(G2frame.FRMC, 'Choose '+fil,G2G.GetImportPath(G2frame),
    47754777                    style=wx.FD_OPEN ,wildcard=fil+'(*.*)|*.*')
     
    49434945            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,False)
    49444946            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,False)
    4945             G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,True)
     4947            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,False)
     4948            #G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,True)
    49464949        if G2frame.FRMC.GetSizer():
    49474950            G2frame.FRMC.GetSizer().Clear(True)
     
    49564959        mainSizer.Add((5,5),0)
    49574960        if G2frame.RMCchoice == 'fullrmc':
    4958             try:
    4959                 import fullrmc
    4960             except ModuleNotFoundError:
    4961                 wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II
    4962            Install it in your python according to the instructions in
    4963            https://bachiraoun.github.io/fullrmc/index.html. ''',
    4964                      caption='fullrmc not installed',style=wx.ICON_INFORMATION)
     4961            if G2pwd.findfullrmc() is None:
     4962                dlg = wx.MessageDialog(G2frame,
     4963                    'The fullrmc code is not installed or could not be'
     4964                    ' located. Do you want help information on fullrmc?',
     4965                    'Install info',
     4966                    wx.YES|wx.NO)
     4967                try:
     4968                    dlg.CenterOnParent()
     4969                    result = dlg.ShowModal()
     4970                finally:
     4971                    dlg.Destroy()
     4972                if result == wx.ID_YES:
     4973                    G2G.ShowHelp('fullrmc',G2frame)
    49654974                return
    4966             if int(fullrmc.__version__.split('.')[0]) < 5:
    4967                 wx.MessageBox('This module requires fullrmc >= 5.0. You have {}.'.format(fullrmc.__version__) +
    4968                         ' Revert to GSAS-II version <=4517 to use older versions of fullrmc. ',
    4969                      caption='fullrmc to old',style=wx.ICON_INFORMATION)
    4970                 return
    4971             mainSizer.Add(wx.StaticText(G2frame.FRMC,label=''' "Fullrmc, a Rigid Body Reverse Monte Carlo Modeling Package Enabled with Machine Learning and Artificial Intelligence",     
    4972  B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. doi: https://doi.org/10.1002/jcc.24304
     4975            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=
     4976''' "Fullrmc, a Rigid Body Reverse Monte Carlo Modeling Package Enabled with
     4977Machine Learning and Artificial Intelligence", B. Aoun, Jour. Comp. Chem.
     4978(2016), 37, 1102-1111. doi: https://doi.org/10.1002/jcc.24304
    49734979 '''))
    49744980            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SETUPRMC,True)
     
    51905196                mainSizer.Add(molecSizer,0)
    51915197            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    5192             mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run file preparation:'),0,WACV)
     5198            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run file preparation:'))
    51935199            resLine = wx.BoxSizer(wx.HORIZONTAL)
    5194             restart = wx.CheckBox(G2frame.FRMC,label=' Restart fullrmc Engine? (will clear old result!) ')
     5200            resLine.Add(wx.StaticText(G2frame.FRMC,label=' Run '),0,WACV)
     5201            resLine.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict,'Cycles',xmin=1,size=[60,25]))
     5202            resLine.Add(wx.StaticText(G2frame.FRMC,
     5203                        label=' Computation cycles of '),0,WACV)
     5204            RMCPdict['Steps/cycle'] = RMCPdict.get('Steps/cycle',5000)
     5205            resLine.Add(G2G.EnumSelector(G2frame.FRMC,RMCPdict,'Steps/cycle',
     5206                        ['1K','5K','10K','50K'],[1000,5000,10000,50000]),0,WACV)
     5207            resLine.Add(wx.StaticText(G2frame.FRMC,
     5208                        label=' steps per cycle'),0,WACV)
     5209            mainSizer.Add(resLine,0)
     5210            resLine = wx.BoxSizer(wx.HORIZONTAL)
     5211            resLine.Add(wx.StaticText(G2frame.FRMC,
     5212                        label=' Restart fullrmc Engine? '),0,WACV)
     5213            restart = wx.CheckBox(G2frame.FRMC,label='(will clear old result!) ')
     5214            resLine.Add(restart,0,WACV)
     5215
    51955216            restart.SetValue(RMCPdict['ReStart'][0])
    51965217            restart.Bind(wx.EVT_CHECKBOX,OnReStart)
    5197             resLine.Add(restart,0,WACV)
    5198             resLine.Add(wx.StaticText(G2frame.FRMC,label=' 10,000X Computation cycles: '),0,WACV)
    5199             resLine.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict,'Cycles',xmin=1,size=[60,25]),0,WACV)
    52005218            mainSizer.Add(resLine,0)
    52015219               
    52025220            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    5203             mainSizer.Add(GetAtmChoice(RMCPdict),0)
     5221            mainSizer.Add(GetAtmChoice(G2frame.FRMC,RMCPdict),0)
    52045222           
    52055223            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
     
    52215239            distBox.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict,'min Contact',xmin=0.,xmax=4.,size=(50,25)),0,WACV)           
    52225240            mainSizer.Add(distBox,0)
    5223             mainSizer.Add(GetPairSizer(RMCPdict),0)
     5241            mainSizer.Add(GetPairSizer(G2frame.FRMC,RMCPdict),0)
    52245242
    52255243            mainSizer.Add((-1,10))
     
    56955713            RMCPdict = data['RMC']['fullrmc']
    56965714            # debug stuff
    5697             #if GSASIIpath.GetConfigValue('debug'):
    5698             #    print('reloading',G2pwd)
    5699             #    import imp
    5700             #    imp.reload(G2pwd)
     5715            # if GSASIIpath.GetConfigValue('debug'):
     5716            #     print('reloading',G2pwd)
     5717            #     import imp
     5718            #     imp.reload(G2pwd)
    57015719            # end debug stuff           
    57025720            rname = G2pwd.MakefullrmcRun(pName,data,RMCPdict)
     
    57715789            #     #import shutil
    57725790            #     #shutil.rmtree(rmcname)
    5773             G2G.G2MessageBox(G2frame,'''For use of fullrmc, please cite:
    5774 
     5791            G2G.G2MessageBox(G2frame,
     5792'''For use of fullrmc, please cite:
    57755793      "Fullrmc, a Rigid Body Reverse Monte Carlo
    57765794      Modeling Package Enabled with Machine Learning
    57775795      and Artificial Intelligence",
    57785796      B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111.
    5779       DOI: https://doi.org/10.1002/jcc.24304''','Please cite fullrmc')
     5797      DOI: https://doi.org/10.1002/jcc.24304
     5798''',
     5799                                 'Please cite fullrmc')
    57805800            ilog = 0
    57815801            while True:
     
    58685888           
    58695889    def OnStopRMC(event):
    5870         if G2frame.RMCchoice == 'fullrmc':
    5871             generalData = data['General']
    5872             pName = G2frame.GSASprojectfile.split('.')[0] + '-' + generalData['Name']
    5873             pName = pName.replace(' ','_')
    5874             engineFilePath = pName+'.rmc'
    5875             if not os.path.exists(engineFilePath):
    5876                 print('fullrmc repository {} not found'.format(engineFilePath))
    5877                 return
    5878             try:
    5879                 from fullrmc import InterceptHook
    5880                 hook = InterceptHook(path=engineFilePath)
    5881                 hook.stop_engine()
    5882                 print('hook.stop_engine() sent to {}'.format(engineFilePath))
    5883             except Exception as msg:
    5884                 print('failed, msg=',msg)
     5890        pass
     5891    #     if G2frame.RMCchoice == 'fullrmc':
     5892    #         generalData = data['General']
     5893    #         pName = G2frame.GSASprojectfile.split('.')[0] + '-' + generalData['Name']
     5894    #         pName = pName.replace(' ','_')
     5895    #         engineFilePath = pName+'.rmc'
     5896    #         if not os.path.exists(engineFilePath):
     5897    #             print('fullrmc repository {} not found'.format(engineFilePath))
     5898    #             return
     5899    #         try:
     5900    #             from fullrmc import InterceptHook
     5901    #             hook = InterceptHook(path=engineFilePath)
     5902    #             hook.stop_engine()
     5903    #             print('hook.stop_engine() sent to {}'.format(engineFilePath))
     5904    #         except Exception as msg:
     5905    #             print('failed, msg=',msg)
    58855906     
    58865907    def OnViewRMC(event):
     
    66786699            atomGrid.SetTable(atomTable,True)
    66796700#            atomGrid.SetScrollRate(0,0)    #get rid of automatic scroll bars
    6680             for c in range(2,5):
     6701            # loop over all cols in table, set cell editor for numerical items
     6702            for c,t in enumerate(colTypes):
     6703                if not t.startswith(wg.GRID_VALUE_FLOAT): continue
    66816704                attr = wx.grid.GridCellAttr()
    66826705                attr.IncRef()               #fix from Jim Hester
     
    67656788#                transGrid.SetScrollRate(0,0)    #get rid of automatic scroll bars
    67666789                Indx[transGrid.GetId()] = Yi
    6767                 for c in range(0,4):
     6790                for c,t in enumerate(transTypes):
     6791                    if not t.startswith(wg.GRID_VALUE_FLOAT): continue
    67686792                    attr = wx.grid.GridCellAttr()
    67696793                    attr.IncRef()               #fix from Jim Hester
Note: See TracChangeset for help on using the changeset viewer.