Changeset 2677 for trunk/GSASIIimgGUI.py
- Timestamp:
- Jan 30, 2017 5:30:07 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimgGUI.py
r2676 r2677 2293 2293 fInp4.SetValue(self.params['pdfprm']) 2294 2294 scanPDFprm() 2295 msg = self.checkPDFprm( )2295 msg = self.checkPDFprm(True) 2296 2296 finally: 2297 2297 dlg.Destroy() 2298 if msg: G2G.G2MessageBox(self,msg,'Warning') 2298 if 'Error' in msg: 2299 print(msg) 2300 lbl = 'PDFPRM error' 2301 else: 2302 msg = 'Information from file {}\n\n{}'.format(self.params['pdfprm'],msg) 2303 lbl = 'PDFPRM information' 2304 G2G.G2MessageBox(self,msg,lbl) 2299 2305 return 2300 2306 … … 2464 2470 lblsizr.Add(sizer) 2465 2471 sizer = wx.BoxSizer(wx.HORIZONTAL) 2466 sizer.Add(wx.StaticText(mnpnl, wx.ID_ANY,'Autocompute PDF '),0,wx.ALIGN_CENTER_VERTICAL)2472 sizer.Add(wx.StaticText(mnpnl, wx.ID_ANY,'Autocompute PDF:'),0,wx.ALIGN_CENTER_VERTICAL) 2467 2473 sizer.Add(G2G.G2CheckBox(mnpnl,'',self.params,'ComputePDF',OnChange=showPDFctrls)) 2468 2474 lbl4a = wx.StaticText(mnpnl, wx.ID_ANY,'Max detector distance: ') … … 2508 2514 showPDFctrls(None) 2509 2515 2510 def checkPDFprm(self): 2511 '''Read in the PDF (.pdfprm) parameter file and check for problems 2516 def checkPDFprm(self,ShowContents=False): 2517 '''Read in the PDF (.pdfprm) parameter file and check for problems. 2518 If ShowContents is True, a formatted text version of some of the file 2519 contents is returned. If errors are found, the return string will contain 2520 the string "Error:" at least once. 2512 2521 ''' 2513 2522 self.pdfControls = {} … … 2528 2537 S = File.readline() 2529 2538 except Exception as err: 2530 msg += 'PDF processing error: Error with open or read of {}'.format(self.params['pdfprm'])2539 msg += 'PDF Processing Error: error with open or read of {}'.format(self.params['pdfprm']) 2531 2540 if GSASIIpath.GetConfigValue('debug'): 2532 2541 print(msg) … … 2536 2545 finally: 2537 2546 if File: File.close() 2538 # may want to offer a substitution when not found 2547 formula = '' 2548 for el in self.pdfControls['ElList']: 2549 if self.pdfControls['ElList'][el]['FormulaNo'] <= 0: continue 2550 if formula: formula += ' ' 2551 formula += '{}({:.1f})'.format(el,self.pdfControls['ElList'][el]['FormulaNo']) 2552 if not formula: 2553 msg += 'Error: no chemical formula in file' 2539 2554 for key in ['Sample Bkg.','Container','Container Bkg.']: 2540 2555 if key not in self.pdfControls: 2541 2556 if msg: msg += '\n' 2542 msg += 'Error ,missing key in self.pdfControls: '+key2557 msg += 'Error: missing key in self.pdfControls: '+key 2543 2558 continue 2559 if msg or not ShowContents: return msg # stop on error 2560 msg += 'Default formula: '+formula+'\n' 2561 for key in ['Sample Bkg.','Container','Container Bkg.']: 2544 2562 name = self.pdfControls[key]['Name'] 2563 mult = self.pdfControls[key].get('Mult',0.0) 2545 2564 if not name: continue 2565 msg += '\n{}: {:.2f} * "{}"'.format(key,mult,name) 2546 2566 if not G2gd.GetPatternTreeItemId(self.G2frame,self.G2frame.root,name): 2547 if msg: msg += '\n' 2548 msg += 'Warning, tree item for PDF '+key+' not present:\n '+name 2567 msg += ' *** missing ***' 2549 2568 return msg 2550 2569 … … 2757 2776 if self.params['ComputePDF']: 2758 2777 msg = self.checkPDFprm() 2759 if 'Error ' in msg:2778 if 'Error:' in msg: 2760 2779 print(msg) 2761 2780 return True 2762 elif msg: 2763 fileList = [] 2764 id, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) 2765 while id: 2766 name = G2frame.PatternTree.GetItemText(id) 2767 if name.startswith('PWDR '): 2768 fileList.append(name) 2769 id, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) 2770 if not fileList: 2771 print(msg) 2772 print('No PWDR entries to select') 2773 return True 2774 for key in ['Sample Bkg.','Container','Container Bkg.']: 2775 name = self.pdfControls[key]['Name'] 2776 if not name: continue 2777 if not G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name): 2778 indx = G2G.ItemSelector(fileList, self, header='Select PDWR item', 2781 fileList = [] 2782 id, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) 2783 while id: 2784 name = G2frame.PatternTree.GetItemText(id) 2785 if name.startswith('PWDR '): fileList.append(name) 2786 id, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) 2787 if not fileList: 2788 print(msg) 2789 print('No PWDR entries to select') 2790 return True 2791 for key in ['Sample Bkg.','Container','Container Bkg.']: 2792 name = self.pdfControls[key]['Name'] 2793 if not name: continue 2794 if not G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name): 2795 indx = G2G.ItemSelector(fileList, self, header='Select PDWR item', 2779 2796 title='Select a PDWR tree item for '+key+'\n(or cancel to quit)') 2780 2781 2782 2783 2797 if indx is None: 2798 print('No PWDR entry selected for '+key) 2799 return True 2800 self.pdfControls[key]['Name'] = fileList[indx] 2784 2801 return False 2785 2802
Note: See TracChangeset
for help on using the changeset viewer.