Changeset 1719 for trunk/GSASII.py
- Timestamp:
- Mar 16, 2015 4:20:06 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1715 r1719 368 368 if not reader.strictExtension: 369 369 choices += "|any file (*.*)|*.*" 370 # get the file(s) 370 # get the file(s) (probably should remove wx.CHANGE_DIR here) 371 371 if multiple: 372 372 mode = style=wx.OPEN | wx.CHANGE_DIR | wx.MULTIPLE 373 373 else: 374 374 mode = style=wx.OPEN | wx.CHANGE_DIR 375 dlg = wx.FileDialog(self, message="Choose "+label+" input file", 376 defaultFile="",wildcard=choices, style=mode) 377 if self.Tutorials: 378 dlg.SetDirectory(os.path.join(GSASIIpath.path2GSAS2,'Exercises')) 379 self.Tutorials = False 380 try: 381 if dlg.ShowModal() == wx.ID_OK: 382 if multiple: 383 filelist = dlg.GetPaths() 384 if len(filelist) == 0: return [] 385 else: 386 filename = dlg.GetPath() 387 filelist = [filename,] 388 os.chdir(dlg.GetDirectory()) # to get Mac/Linux to change directory! 389 else: # cancel was pressed 390 return [] 391 finally: 392 dlg.Destroy() 375 filelist = self.GetImportFile(message="Choose "+label+" input file", 376 defaultFile="",wildcard=choices, style=mode) 393 377 rd_list = [] 394 378 filelist1 = [] … … 539 523 self.Bind(wx.EVT_MENU, self.OnImportPhase, id=item.GetId()) 540 524 525 def GetImportFile(self, message, defaultDir="", defaultFile="", style=wx.OPEN, 526 *args, **kwargs): 527 '''Defines a customized dialog that gets gets files from the appropriate 528 Import directory (unless overridden with defaultDir). The default 529 import directory is found in self.ImportDir, which will be set to 530 the location of the (first) file entered in this dialog. 531 532 :returns: a list of files or an empty list 533 ''' 534 dlg = wx.FileDialog(self, message, defaultDir, defaultFile, *args, 535 style=style, **kwargs) 536 if not defaultDir and self.ImportDir: 537 dlg.SetDirectory(self.ImportDir) 538 try: 539 if dlg.ShowModal() == wx.ID_OK: 540 if style & wx.MULTIPLE: 541 filelist = dlg.GetPaths() 542 if len(filelist) == 0: return [] 543 else: 544 filelist = [dlg.GetPath(),] 545 # not sure if we want to do this (why use wx.CHANGE_DIR?) 546 if style & wx.CHANGE_DIR: # to get Mac/Linux to change directory like windows! 547 os.chdir(dlg.GetDirectory()) 548 if not defaultDir and self.ImportDir: # if we are using a default and 549 # user moved, save the new location 550 self.ImportDir = os.path.split(filelist[0])[0] 551 #print 'default moved to',self.ImportDir 552 else: # cancel was pressed 553 return [] 554 finally: 555 dlg.Destroy() 556 return filelist 557 541 558 def OnImportPhase(self,event): 542 559 '''Called in response to an Import/Phase/... menu item … … 2134 2151 self.StrainKey = '' #ditto for new strain d-zeros 2135 2152 self.EnablePlot = True 2136 self.Tutorials = False #used for changing default directory 2153 if GSASIIpath.GetConfigValue('Starting_directory'): 2154 try: 2155 os.chdir(GSASIIpath.GetConfigValue('Starting_directory')) 2156 except: 2157 print('Ignoring Config Starting_directory value: '+ 2158 GSASIIpath.GetConfigValue('Starting_directory')) 2137 2159 arg = sys.argv 2138 2160 if len(arg) > 1 and arg[1]: … … 2147 2169 except: 2148 2170 print 'Error opening file',arg[1] 2171 2172 self.ImportDir = os.path.normpath(os.getcwd()) # specifies a default path to be used for imports 2173 if GSASIIpath.GetConfigValue('Import_directory'): 2174 self.ImportDir = GSASIIpath.GetConfigValue('Import_directory') 2149 2175 2150 2176 def OnSize(self,event):
Note: See TracChangeset
for help on using the changeset viewer.