Changeset 5373 for trunk/GSASIIdataGUI.py
- Timestamp:
- Nov 17, 2022 10:59:43 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r5362 r5373 678 678 '''Add items to File menu 679 679 ''' 680 item = parent.Append(wx.ID_ANY,'&Open project...\tCtrl+O','Open a GSAS-II project file (*.gpx)')680 item = parent.Append(wx.ID_ANY,'&Open project...\tCtrl+O','Open a GSAS-II project (.gpx) file') 681 681 self.Bind(wx.EVT_MENU, self.OnFileOpen, id=item.GetId()) 682 682 if sys.platform == "darwin": 683 item = parent.Append(wx.ID_ANY,'&Open in new window...','Open a GSAS-II project file (*.gpx)in a separate process')683 item = parent.Append(wx.ID_ANY,'&Open in new window...','Open a GSAS-II project (.gpx) file in a separate process') 684 684 self.Bind(wx.EVT_MENU, self.OnNewGSASII, id=item.GetId()) 685 item = parent.Append(wx.ID_ANY,'Reopen recent...\tCtrl+E','Reopen a previously used GSAS-II project file (*.gpx)')685 item = parent.Append(wx.ID_ANY,'Reopen recent...\tCtrl+E','Reopen a previously used GSAS-II project (.gpx) file') 686 686 self.Bind(wx.EVT_MENU, self.OnFileReopen, id=item.GetId()) 687 item = parent.Append(wx.ID_ANY,'&Open w/project browser\tCtrl+B','Use project browser to a GSAS-II project (.gpx) file') 688 self.Bind(wx.EVT_MENU, self.OnFileBrowse, id=item.GetId()) 687 689 item = parent.Append(wx.ID_ANY,'&Save project\tCtrl+S','Save project under current name') 688 690 self.Bind(wx.EVT_MENU, self.OnFileSave, id=item.GetId()) … … 4325 4327 print('file not found',f) 4326 4328 4329 def _SaveOld(self): 4330 '''See if we should save current project and continue 4331 to read another. 4332 returns True if the project load should continue 4333 ''' 4334 if self.dataWindow: 4335 self.dataWindow.ClearData() 4336 dlg = wx.MessageDialog(self, 4337 'Do you want to save and replace the current project?\n' 4338 '(Use No to read without saving or Cancel to continue ' 4339 'with current project)', 4340 'Save & Overwrite?', 4341 wx.YES|wx.NO|wx.CANCEL) 4342 try: 4343 result = dlg.ShowModal() 4344 finally: 4345 dlg.Destroy() 4346 if result == wx.ID_NO: 4347 result = True 4348 elif result == wx.ID_CANCEL: 4349 return False 4350 else: 4351 if not self.OnFileSave(None): 4352 return False 4353 self.GPXtree.DeleteChildren(self.root) 4354 self.GSASprojectfile = '' 4355 self.HKL = [] 4356 self.Extinct = [] 4357 if self.G2plotNB.plotList: 4358 self.G2plotNB.clear() 4359 return True 4360 4327 4361 def OnFileOpen(self, event, filename=None): 4328 4362 '''Gets a GSAS-II .gpx project file in response to the 4329 4363 File/Open Project menu button 4330 4364 ''' 4331 def SaveOld():4332 '''See if we should save current project and continue4333 to read another.4334 returns True if the project load should continue4335 '''4336 if self.dataWindow:4337 self.dataWindow.ClearData()4338 dlg = wx.MessageDialog(self,4339 'Do you want to save and replace the current project?\n(Use No to read without saving or Cancel to continue with current project)',4340 'Save & Overwrite?',4341 wx.YES|wx.NO|wx.CANCEL)4342 try:4343 result = dlg.ShowModal()4344 finally:4345 dlg.Destroy()4346 if result == wx.ID_NO:4347 result = True4348 elif result == wx.ID_CANCEL:4349 return False4350 else:4351 if not self.OnFileSave(None): return False4352 self.GPXtree.DeleteChildren(self.root)4353 self.GSASprojectfile = ''4354 self.HKL = []4355 self.Extinct = []4356 if self.G2plotNB.plotList:4357 self.G2plotNB.clear()4358 return True4359 4365 4360 4366 def GetGPX(): … … 4376 4382 self.EnablePlot = False 4377 4383 if self.GPXtree.GetChildrenCount(self.root,False): 4378 if not SaveOld(): return4384 if not self._SaveOld(): return 4379 4385 4380 4386 if not filename: … … 4398 4404 print (traceback.format_exc()) 4399 4405 4406 def OnFileBrowse(self, event): 4407 '''Gets a GSAS-II .gpx project using the GPX browser, in response 4408 to the File/"Open Project browser" menu button 4409 ''' 4410 self.EnablePlot = False 4411 if self.LastGPXdir: 4412 pth = self.LastGPXdir 4413 else: 4414 pth = '.' 4415 4416 try: 4417 dlg = G2G.gpxFileSelector(parent=self,startdir=pth) 4418 if wx.ID_OK == dlg.ShowModal(): 4419 filename = dlg.Selection 4420 else: 4421 return 4422 finally: 4423 dlg.Destroy() 4424 4425 if self.GPXtree.GetChildrenCount(self.root,False): 4426 if not self._SaveOld(): return # cancel was entered; nothing changed 4427 self.GSASprojectfile = filename 4428 self.LastGPXdir = os.path.split(os.path.abspath(filename))[0] 4429 4430 self.init_vars() 4431 try: 4432 self.StartProject() #open the file if possible 4433 except: 4434 print ('\nError opening file '+filename) 4435 import traceback 4436 print (traceback.format_exc()) 4437 4438 4400 4439 def StartProject(self): 4401 4440 '''Opens a GSAS-II project file & selects the 1st available data set to
Note: See TracChangeset
for help on using the changeset viewer.