Changeset 4887


Ignore:
Timestamp:
Apr 19, 2021 9:50:52 PM (2 years ago)
Author:
toby
Message:

deal with 0 on elem sym; save binary path; support ..._exec in config

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElem.py

    r4659 r4887  
    216216    if El not in atmdata.XrayFF and El not in atmdata.MagFF:
    217217        if ElS not in atmdata.XrayFF:
    218             print('Atom type '+El+' not found, using H')
    219             ElS = 'H'
    220 #            return # not sure what this element should be!
     218            if ElS.endswith('0') and ElS[:-1] in atmdata.XrayFF:
     219                ElS = ElS[:-1]
     220            else:
     221                ElS = 'H'
    221222        print('Atom type '+El+' not found, using '+ElS)
    222223        El = ElS
  • trunk/GSASIIctrlGUI.py

    r4884 r4887  
    58775877            self.OnChange()
    58785878        dlg.Destroy()
     5879
     5880    def onSelExec(self,event):
     5881        'Select an executable file from a menu'
     5882        var = self.choice[0]
     5883        is_exe = lambda fpath: os.path.isfile(fpath) and os.access(fpath, os.X_OK)
     5884        defD = defF = ''
     5885        if self.vars[var][1] is not None and os.path.exists(self.vars[var][1]):
     5886            defD,defF=os.path.split(self.vars[var][1])
     5887        repeat = True
     5888        while repeat:
     5889            repeat = False
     5890            if sys.platform == "win32":
     5891                dlg = wx.FileDialog(self, "Choose a .exe file:",
     5892                                defaultDir=defD,defaultFile=defF,
     5893                                style=wx.FD_DEFAULT_STYLE|wx.FD_FILE_MUST_EXIST,
     5894                                wildcard="Executable files|*.exe")
     5895            else:
     5896                dlg = wx.FileDialog(self, "Choose an executable image:",
     5897                                defaultDir=defD,defaultFile=defF,
     5898                                style=wx.FD_DEFAULT_STYLE|wx.FD_FILE_MUST_EXIST)
     5899            if dlg.ShowModal() == wx.ID_OK:
     5900                val = dlg.GetPath()
     5901                if os.path.exists(val) and is_exe(val):
     5902                    self.vars[var][1] = val
     5903                    self.strEd.SetValue(self.vars[var][1])
     5904                    self.OnChange()
     5905                else:
     5906                    dlg.Destroy()
     5907                    G2MessageBox(self,'File not found or not executable',
     5908                                     'Invalid file')
     5909                    repeat = True
     5910                    continue
     5911        dlg.Destroy()
     5912
    58795913       
    58805914    def OnSelection(self):
    5881         'show a selected variable'
     5915        'show a selected variable and allow it to be changed'
    58825916        def OnNewColorBar(event):
    58835917            self.vars['Contour_color'][1] = self.colSel.GetValue()
     
    59275961            if var.endswith('_directory') or var.endswith('_location'):
    59285962                btn = wx.Button(self,wx.ID_ANY,'Select from dialog...')
     5963                btn.Bind(wx.EVT_BUTTON,self.onSelDir)
     5964                sz = (400,-1)
     5965            elif var.endswith('_exec'):
     5966                btn = wx.Button(self,wx.ID_ANY,'Select from dialog...')
     5967                btn.Bind(wx.EVT_BUTTON,self.onSelExec)
    59295968                sz = (400,-1)
    59305969            else:
     
    59515990                if self.vars[var][1] is not None:
    59525991                    self.strEd.SetValue(self.vars[var][1])
    5953                 self.varsizer.Add(self.strEd, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    5954             if btn:
    5955                 btn.Bind(wx.EVT_BUTTON,self.onSelDir)
    5956                 self.varsizer.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     5992                if btn:
     5993                    self.varsizer.Add(self.strEd, 0, wx.ALL|wx.EXPAND, 5)
     5994                    self.varsizer.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     5995                else:
     5996                    self.varsizer.Add(self.strEd, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    59575997        # button for reset to default value
    59585998        lbl = "Reset to Default"
     
    72487288# Deal with Origin 1/2 ambiguities ################################################################################
    72497289def ChooseOrigin(G2frame,rd):   
     7290    G2elem.SetupGeneral(rd.Phase,G2frame.dirname)
    72507291    # make copy of Phase but shift atoms Origin 1->2
    72517292    O2Phase = copy.deepcopy(rd.Phase)
     
    72857326            if i: txt += ', '
    72867327            txt += '{}*{}'.format(cellContents[k],k)
    7287         G2elem.SetupGeneral(phObj,G2frame.dirname)
    72887328        den,_ = G2mth.getDensity(phObj['General'])
    72897329        txt += "\n   Density {:.2f} g/cc\n".format(den)
  • trunk/GSASIIpath.py

    r4741 r4887  
    10121012
    10131013BinaryPathLoaded = False
     1014binaryPath = ''
    10141015def SetBinaryPath(printInfo=False, loadBinary=True):
    10151016    '''
     
    10201021    '''
    10211022    # do this only once no matter how many times it is called
    1022     global BinaryPathLoaded
     1023    global BinaryPathLoaded,binaryPath
    10231024    if BinaryPathLoaded: return
    10241025    try:
     
    10571058    if binpath:                                            # were GSAS-II binaries found
    10581059        sys.path.insert(0,binpath)
     1060        binaryPath = binpath
    10591061        if printInfo:
    10601062            print('GSAS-II binary directory: {}'.format(binpath))
     
    10741076                print('GSAS-II binary directory: {}'.format(binpath))
    10751077            sys.path.insert(0,binpath)
     1078            binaryPath = binpath
    10761079            BinaryPathLoaded = True
    10771080        # this must be imported before anything that imports any .pyd/.so file for GSASII
     
    11071110                if TestSPG(fpth):
    11081111                    sys.path.insert(0,binpath)
     1112                    binaryPath = binpath
    11091113                    if printInfo:
    11101114                        print('\n'+75*'*')
Note: See TracChangeset for help on using the changeset viewer.