Changeset 2109
- Timestamp:
- Dec 26, 2015 10:22:09 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2101 r2109 153 153 kind=wx.ITEM_NORMAL,text='&New project') 154 154 self.Bind(wx.EVT_MENU, self.OnFileClose, id=item.GetId()) 155 item = parent.Append(wx.ID_PREFERENCES, text = "&Preferences") 156 self.Bind(wx.EVT_MENU, self.OnPreferences, item) 157 if GSASIIpath.GetConfigValue('debug'): 158 def OnIPython(event): 159 GSASIIpath.IPyBreak() 160 item = parent.Append(wx.ID_ANY, text = "IPython Console") 161 self.Bind(wx.EVT_MENU, OnIPython, item) 155 162 item = parent.Append( 156 163 help='Exit from GSAS-II', id=wx.ID_ANY, … … 412 419 if not reader.strictExtension: 413 420 choices += "|any file (*.*)|*.*" 414 # get the file(s) (probably should remove wx.CHANGE_DIR here)421 # get the file(s) 415 422 if multiple: 416 mode = style=wx.OPEN | wx. CHANGE_DIR | wx.MULTIPLE423 mode = style=wx.OPEN | wx.MULTIPLE 417 424 else: 418 mode = style=wx.OPEN | wx.CHANGE_DIR419 filelist = self.GetImportFile(message="Choose "+label+" input file",425 mode = style=wx.OPEN 426 filelist = G2G.GetImportFile(self,message="Choose "+label+" input file", 420 427 defaultFile="",wildcard=choices, style=mode) 421 428 rd_list = [] … … 549 556 text='guess format from file') 550 557 self.Bind(wx.EVT_MENU, self.OnImportPhase, id=item.GetId()) 551 552 def GetImportFile(self, message, defaultDir="", defaultFile="", style=wx.OPEN,553 *args, **kwargs):554 '''Defines a customized dialog that gets gets files from the appropriate555 Import directory (unless overridden with defaultDir). The default556 import directory is found in self.ImportDir, which will be set to557 the location of the (first) file entered in this dialog.558 559 :returns: a list of files or an empty list560 '''561 dlg = wx.FileDialog(self, message, defaultDir, defaultFile, *args,562 style=style, **kwargs)563 if not defaultDir and self.ImportDir:564 dlg.SetDirectory(self.ImportDir)565 try:566 if dlg.ShowModal() == wx.ID_OK:567 if style & wx.MULTIPLE:568 filelist = dlg.GetPaths()569 if len(filelist) == 0: return []570 else:571 filelist = [dlg.GetPath(),]572 # not sure if we want to do this (why use wx.CHANGE_DIR?)573 if style & wx.CHANGE_DIR: # to get Mac/Linux to change directory like windows!574 os.chdir(dlg.GetDirectory())575 if not defaultDir and self.ImportDir: # if we are using a default and576 # user moved, save the new location577 self.ImportDir = os.path.split(filelist[0])[0]578 #print 'default moved to',self.ImportDir579 else: # cancel was pressed580 return []581 finally:582 dlg.Destroy()583 return filelist584 558 585 559 def OnImportPhase(self,event): … … 1314 1288 while True: # loop until we get a file that works or we get a cancel 1315 1289 instfile = '' 1290 pth = G2G.GetImportPath(self) 1291 if not pth: pth = '.' 1316 1292 dlg = wx.FileDialog( 1317 1293 self, 1318 'Choose inst. param file for "' 1319 +rd.idstring 1320 +'" (or Cancel for default)', 1321 '.', '', 1294 'Choose inst. param file for "'+rd.idstring+'" (or Cancel for default)', 1295 pth, '', 1322 1296 'GSAS iparm file (*.prm,*.inst,*.ins)|*.prm;*.inst;*.ins|' 1323 1297 'GSAS-II iparm file (*.instprm)|*.instprm|' 1324 'All files (*.*)|*.*', 1325 wx.OPEN|wx.CHANGE_DIR) 1298 'All files (*.*)|*.*', wx.OPEN) 1326 1299 if os.path.exists(lastIparmfile): 1327 1300 dlg.SetFilename(lastIparmfile) … … 1876 1849 'Choose an file to save past actions', '.', defnam, 1877 1850 'GSAS-II cmd output (*.gcmd)|*.gcmd', 1878 wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT |wx.CHANGE_DIR)1851 wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1879 1852 dlg.CenterOnParent() 1880 1853 try: … … 1907 1880 'Choose an file to read saved actions', '.', defnam, 1908 1881 'GSAS-II cmd output (*.gcmd)|*.gcmd', 1909 wx.OPEN |wx.CHANGE_DIR)1882 wx.OPEN) 1910 1883 dlg.CenterOnParent() 1911 1884 try: … … 2105 2078 self._Add_ImportMenu_Sfact(Import) 2106 2079 self._Add_ImportMenu_smallangle(Import) 2107 item = File.Append(wx.ID_PREFERENCES, text = "&Preferences")2108 self.Bind(wx.EVT_MENU, self.OnPreferences, item)2109 2080 2110 2081 #====================================================================== … … 2156 2127 ]) 2157 2128 menubar.Append(menu=HelpMenu,title='&Help') 2158 2129 2159 2130 def _init_ctrls(self, parent): 2160 2131 wx.Frame.__init__(self, name='GSASII', parent=parent, … … 2229 2200 self.oldFocus = None 2230 2201 self.GSASprojectfile = '' 2231 self.dirname = os.path.expanduser('~') #start in the users home directory by default; may be meaningless2232 self.exportDir = None # the last directory used for exports, if any.2233 2202 self.undofile = '' 2234 2203 self.TreeItemDelete = False … … 2282 2251 self.EnablePlot = True 2283 2252 self.hist = '' # selected histogram in Phase/Data tab 2284 if GSASIIpath.GetConfigValue('Starting_directory'):2285 try:2286 os.chdir(GSASIIpath.GetConfigValue('Starting_directory'))2287 except:2288 print('Ignoring Config Starting_directory value: '+2289 GSASIIpath.GetConfigValue('Starting_directory'))2253 self.dirname = os.path.expanduser('~') #start in the users home directory by default; may be meaningless 2254 self.TutorialImportDir = None # location to read tutorial files, set when a tutorial is viewed 2255 self.LastImportDir = None # last-used directory where an import was done 2256 self.LastGPXdir = None # directory where a GPX file was last read 2257 self.LastExportDir = None # the last directory used for exports, if any. 2258 2290 2259 arg = sys.argv 2291 2260 if len(arg) > 1 and arg[1]: … … 2295 2264 try: 2296 2265 self.StartProject() #open the file if possible 2266 return 2297 2267 except Exception: 2298 2268 print 'Error opening or reading file',arg[1] 2299 2269 import traceback 2300 2270 print traceback.format_exc() 2301 2302 self.ImportDir = os.path.normpath(os.getcwd()) # specifies a default path to be used for imports 2303 if GSASIIpath.GetConfigValue('Import_directory'): 2304 self.ImportDir = GSASIIpath.GetConfigValue('Import_directory') 2305 2271 2272 if GSASIIpath.GetConfigValue('Starting_directory'): 2273 try: 2274 pth = GSASIIpath.GetConfigValue('Starting_directory') 2275 pth = os.path.expanduser(pth) 2276 os.chdir(pth) 2277 self.LastGPXdir = pth 2278 except: 2279 print('Ignoring Config Starting_directory value: '+ 2280 GSASIIpath.GetConfigValue('Starting_directory')) 2281 2306 2282 def GetTreeItemsList(self,item): 2307 2283 return self.PatternTree._getTreeItemsList(item) … … 2419 2395 Cuka = 1.54052 2420 2396 self.CheckNotebook() 2421 dlg = wx.FileDialog(self, 'Choose file with peak list', '.', '', 2422 'peak files (*.txt)|*.txt|All files (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR) 2397 pth = G2G.GetImportPath(self) 2398 if not pth: pth = '.' 2399 dlg = wx.FileDialog(self, 'Choose file with peak list', pth, '', 2400 'peak files (*.txt)|*.txt|All files (*.*)|*.*',wx.OPEN) 2423 2401 try: 2424 2402 if dlg.ShowModal() == wx.ID_OK: … … 2462 2440 'Zip archive (*.zip)|*.zip|' 2463 2441 'All files (*.*)|*.*', 2464 wx.OPEN | wx.MULTIPLE |wx.CHANGE_DIR)2442 wx.OPEN | wx.MULTIPLE) 2465 2443 try: 2466 2444 if dlg.ShowModal() == wx.ID_OK: … … 2795 2773 Id = self.PatternTree.AppendItem(parent=self.root,text=outname) 2796 2774 if Id: 2797 dlg = wx.FileDialog(self, 'Choose sum image filename', '.', '', 2775 pth = G2G.GetExportPath(self) 2776 dlg = wx.FileDialog(self, 'Choose sum image filename', pth, '', 2798 2777 'G2img files (*.G2img)|*.G2img', 2799 wx.SAVE|wx.FD_OVERWRITE_PROMPT |wx.CHANGE_DIR)2778 wx.SAVE|wx.FD_OVERWRITE_PROMPT) 2800 2779 if dlg.ShowModal() == wx.ID_OK: 2801 2780 newimagefile = dlg.GetPath() … … 3000 2979 dlg = wx.MessageDialog( 3001 2980 self, 3002 'Do you want to overwrite the current project? ' 3003 'Any unsaved changes will be lost. Press OK to continue.',2981 'Do you want to overwrite the current project? '+ 2982 'Any unsaved changes in current project will be lost. Press OK to continue.', 3004 2983 'Overwrite?', wx.OK | wx.CANCEL) 3005 2984 try: … … 3017 2996 if not filename: 3018 2997 if self.dataDisplay: self.dataDisplay.Destroy() 3019 dlg = wx.FileDialog(self, 'Choose GSAS-II project file', '.', '', 3020 'GSAS-II project file (*.gpx)|*.gpx',wx.OPEN|wx.CHANGE_DIR) 2998 if self.LastGPXdir: 2999 pth = self.LastGPXdir 3000 else: 3001 pth = '.' 3002 dlg = wx.FileDialog(self, 'Choose GSAS-II project file', pth, 3003 wildcard='GSAS-II project file (*.gpx)|*.gpx',style=wx.OPEN) 3021 3004 try: 3022 3005 if dlg.ShowModal() != wx.ID_OK: return … … 3063 3046 self.CheckNotebook() 3064 3047 if self.dirname: os.chdir(self.dirname) # to get Mac/Linux to change directory! 3048 pth = os.path.split(os.path.abspath(self.GSASprojectfile))[0] 3049 if GSASIIpath.GetConfigValue('Save_paths'): G2G.SaveGPXdirectory(pth) 3050 self.LastGPXdir = pth 3065 3051 3066 3052 def OnFileClose(self, event): … … 3103 3089 File/Save as menu button 3104 3090 ''' 3105 dlg = wx.FileDialog(self, 'Choose GSAS-II project file name', '.', '', 3106 'GSAS-II project file (*.gpx)|*.gpx',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 3091 if GSASIIpath.GetConfigValue('Starting_directory'): 3092 pth = GSASIIpath.GetConfigValue('Starting_directory') 3093 pth = os.path.expanduser(pth) 3094 elif self.LastGPXdir: 3095 pth = self.LastGPXdir 3096 else: 3097 pth = '.' 3098 dlg = wx.FileDialog(self, 'Choose GSAS-II project file name', pth, '', 3099 'GSAS-II project file (*.gpx)|*.gpx',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3107 3100 try: 3108 3101 if dlg.ShowModal() == wx.ID_OK: … … 3133 3126 3134 3127 def OnExportPeakList(self,event): 3135 dlg = wx.FileDialog(self, 'Choose output peak list file name', '.', '', 3136 '(*.*)|*.*',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 3128 pth = G2G.GetExportPath(self) 3129 dlg = wx.FileDialog(self, 'Choose output peak list file name', pth, '', 3130 '(*.*)|*.*',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3137 3131 try: 3138 3132 if dlg.ShowModal() == wx.ID_OK: … … 3179 3173 3180 3174 def OnExportHKL(self,event): 3181 dlg = wx.FileDialog(self, 'Choose output reflection list file name', '.', '', 3182 '(*.*)|*.*',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 3175 pth = G2G.GetExportPath(self) 3176 dlg = wx.FileDialog(self, 'Choose output reflection list file name', pth, '', 3177 '(*.*)|*.*',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3183 3178 try: 3184 3179 if dlg.ShowModal() == wx.ID_OK: … … 3729 3724 self.main.PackageVersions.append([' Platform',sys.platform+' '+platform.architecture()[0]+' '+platform.machine()]) 3730 3725 3731 # self.main.PackageVersions = {}3732 # self.main.PackageVersions['Python'] = sys.version.split()[0]3733 # for p in (wx,mpl,np,sp,ogl):3734 # self.main.PackageVersions[p.__name__] = p.__version__3735 # try:3736 # self.main.PackageVersions[Image.__name__] = Image.VERSION3737 # except:3738 # try:3739 # from PIL import PILLOW_VERSION3740 # self.main.PackageVersions[Image.__name__] = PILLOW_VERSION3741 # except:3742 # pass3743 # self.main.PackageVersions[' Platform'] = sys.platform+' '+platform.architecture()[0]+' '+platform.machine()3744 # DEBUG: jump to sequential results3745 #Id = G2gd.GetPatternTreeItemId(self.main,self.main.root,'Sequential results')3746 #self.main.PatternTree.SelectItem(Id)3747 # end DEBUG3748 3726 return True 3749 3727 # def MacOpenFile(self, filename): -
trunk/GSASIIIO.py
r2093 r2109 188 188 189 189 if not os.path.exists(imagefile): 190 dlg = wx.FileDialog(G2frame, 'Previous image file not found; open here', '.', '',\ 191 'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor;*.stl)\ 192 |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor;*.stl|\ 193 European detector file (*.edf)|*.edf|\ 194 Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|\ 195 MAR file (*.mar*)|*.mar*|\ 196 GE Image (*.ge*;*.avg;*.sum;*.cor)|*.ge*;*.avg;*.sum;*.cor|\ 197 ADSC Image (*.img)|*.img|\ 198 Rigaku-Axis4 (*.stl)|*.stl|\ 199 All files (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR) 190 prevnam = os.path.split(imagefile)[1] 191 prevext = os.path.splitext(imagefile)[1] 192 wildcard = 'Image format (*'+prevext+')|*'+prevext 193 dlg = wx.FileDialog(G2frame, 'Previous image file ('+prevnam+') not found; open here', '.', prevnam, 194 wildcard,wx.OPEN) 200 195 try: 201 196 dlg.SetFilename(''+ospath.split(imagefile)[1]) … … 867 862 cPickle.dump(data,file,1) 868 863 file.close() 864 pth = os.path.split(os.path.abspath(G2frame.GSASprojectfile))[0] 865 if GSASIIpath.GetConfigValue('Save_paths'): G2G.SaveGPXdirectory(pth) 866 G2frame.LastGPXdir = pth 869 867 finally: 870 868 wx.EndBusyCursor() … … 2191 2189 :returns: a file name (str) or None if Cancel is pressed 2192 2190 ''' 2191 2192 pth = G2G.GetExportPath(self.G2frame) 2193 2193 defnam = os.path.splitext( 2194 2194 os.path.split(self.G2frame.GSASprojectfile)[1] 2195 2195 )[0]+self.extension 2196 2196 dlg = wx.FileDialog( 2197 self.G2frame, 'Input name for file to write', '.', defnam,2197 self.G2frame, 'Input name for file to write', pth, defnam, 2198 2198 self.longFormatName+' (*'+self.extension+')|*'+self.extension, 2199 wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT |wx.CHANGE_DIR)2199 wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 2200 2200 dlg.CenterOnParent() 2201 2201 try: 2202 2202 if dlg.ShowModal() == wx.ID_OK: 2203 2203 filename = dlg.GetPath() 2204 # make sure extension is correct2205 filename = os.path.splitext(filename)[0]+self.extension 2204 self.G2frame.LastExportDir = os.path.split(filename)[0] 2205 filename = os.path.splitext(filename)[0]+self.extension # make sure extension is correct 2206 2206 else: 2207 2207 filename = None … … 2216 2216 :returns: a directory name (str) or None if Cancel is pressed 2217 2217 ''' 2218 if self.G2frame.exportDir: 2219 startdir = self.G2frame.exportDir 2220 elif self.G2frame.GSASprojectfile: 2221 startdir = os.path.split(self.G2frame.GSASprojectfile)[0] 2222 elif self.G2frame.dirname: 2223 startdir = self.G2frame.dirname 2224 else: 2225 startdir = '' 2218 pth = G2G.GetExportPath(self.G2frame) 2226 2219 dlg = wx.DirDialog( 2227 self.G2frame, 'Input directory where file(s) will be written', startdir,2220 self.G2frame, 'Input directory where file(s) will be written', pth, 2228 2221 wx.DD_DEFAULT_STYLE) 2229 2222 dlg.CenterOnParent() … … 2231 2224 if dlg.ShowModal() == wx.ID_OK: 2232 2225 filename = dlg.GetPath() 2233 self.G2frame. exportDir = filename2226 self.G2frame.LastExportDir = filename 2234 2227 else: 2235 2228 filename = None -
trunk/GSASIIctrls.py
r2100 r2109 2404 2404 2405 2405 ################################################################################ 2406 def GetImportFile(G2frame, message, defaultDir="", defaultFile="", style=wx.OPEN, 2407 *args, **kwargs): 2408 '''Uses a customized dialog that gets files from the appropriate import directory. 2409 Arguments are used the same as in :func:`wx.FileDialog`. Selection of 2410 multiple files is allowed if argument style includes wx.MULTIPLE. 2411 2412 The default initial directory (unless overridden with argument defaultDir) 2413 is found in G2frame.TutorialImportDir, config setting Import_directory or 2414 G2frame.LastImportDir, see :func:`GetImportPath`. 2415 2416 The path of the first file entered is used to set G2frame.LastImportDir 2417 and optionally config setting Import_directory. 2418 2419 :returns: a list of files or an empty list 2420 ''' 2421 dlg = wx.FileDialog(G2frame, message, defaultDir, defaultFile, *args, 2422 style=style, **kwargs) 2423 pth = GetImportPath(G2frame) 2424 if not defaultDir and pth: dlg.SetDirectory(pth) 2425 try: 2426 if dlg.ShowModal() == wx.ID_OK: 2427 if style & wx.MULTIPLE: 2428 filelist = dlg.GetPaths() 2429 if len(filelist) == 0: return [] 2430 else: 2431 filelist = [dlg.GetPath(),] 2432 # not sure if we want to do this (why use wx.CHANGE_DIR?) 2433 if style & wx.CHANGE_DIR: # to get Mac/Linux to change directory like windows! 2434 os.chdir(dlg.GetDirectory()) 2435 else: # cancel was pressed 2436 return [] 2437 finally: 2438 dlg.Destroy() 2439 # save the path of the first file and reset the TutorialImportDir variable 2440 pth = os.path.split(os.path.abspath(filelist[0]))[0] 2441 if GSASIIpath.GetConfigValue('Save_paths'): G2G.SaveImportDirectory(pth) 2442 G2frame.LastImportDir = pth 2443 G2frame.TutorialImportDir = None 2444 return filelist 2445 2446 def GetImportPath(G2frame): 2447 '''Determines the default location to use for importing files. Tries sequentially 2448 G2frame.TutorialImportDir, config var Import_directory and G2frame.LastImportDir. 2449 2450 :returns: a string containing the path to be used when reading files or None 2451 if none of the above are specified. 2452 ''' 2453 if G2frame.TutorialImportDir: 2454 if os.path.exists(G2frame.TutorialImportDir): 2455 return G2frame.TutorialImportDir 2456 elif GSASIIpath.GetConfigValue('debug'): 2457 print('Tutorial location (TutorialImportDir) not found: '+G2frame.TutorialImportDir) 2458 pth = GSASIIpath.GetConfigValue('Import_directory') 2459 if pth: 2460 pth = os.path.expanduser(pth) 2461 if os.path.exists(pth): 2462 return pth 2463 elif GSASIIpath.GetConfigValue('debug'): 2464 print('Ignoring Config Import_directory value: '+ 2465 GSASIIpath.GetConfigValue('Import_directory')) 2466 if G2frame.LastImportDir: 2467 if os.path.exists(G2frame.LastImportDir): 2468 return G2frame.LastImportDir 2469 elif GSASIIpath.GetConfigValue('debug'): 2470 print('Warning: G2frame.LastImportDir not found = '+G2frame.LastImportDir) 2471 return None 2472 2473 def GetExportPath(G2frame): 2474 '''Determines the default location to use for writing files. Tries sequentially 2475 G2frame.LastExportDir and G2frame.LastGPXdir. 2476 2477 :returns: a string containing the path to be used when writing files or '.' 2478 if none of the above are specified. 2479 ''' 2480 if G2frame.LastExportDir: 2481 return G2frame.LastExportDir 2482 elif G2frame.LastGPXdir: 2483 return G2frame.LastGPXdir 2484 else: 2485 return '.' 2486 2487 ################################################################################ 2406 2488 ##### Customized Grid Support 2407 2489 ################################################################################ … … 3150 3232 3151 3233 ################################################################################ 3234 # configuration routines (for editing config.py) 3235 def SaveGPXdirectory(path): 3236 import config_example 3237 vars = GetConfigValsDocs() 3238 try: 3239 vars['Starting_directory'][1] = path 3240 if GSASIIpath.GetConfigValue('debug'): print('Saving GPX path: '+path) 3241 SaveConfigVars(vars) 3242 except KeyError: 3243 pass 3244 3245 def SaveImportDirectory(path): 3246 import config_example 3247 vars = GetConfigValsDocs() 3248 try: 3249 vars['Import_directory'][1] = path 3250 if GSASIIpath.GetConfigValue('debug'): print('Saving Import path: '+path) 3251 SaveConfigVars(vars) 3252 except KeyError: 3253 pass 3254 3255 def GetConfigValsDocs(): 3256 '''Reads the module referenced in fname (often <module>.__file__) and 3257 return a dict with names of global variables as keys. 3258 For each global variable, the value contains four items: 3259 3260 :returns: a dict where keys are names defined in module config_example.py 3261 where the value is a list of four items, as follows: 3262 3263 * item 0: the default value 3264 * item 1: the current value 3265 * item 2: the initial value (starts same as item 1) 3266 * item 3: the "docstring" that follows variable definition 3267 3268 ''' 3269 import config_example 3270 import ast 3271 fname = os.path.splitext(config_example.__file__)[0]+'.py' # convert .pyc to .py 3272 with open(fname, 'r') as f: 3273 fstr = f.read() 3274 fstr = fstr.replace('\r\n', '\n').replace('\r', '\n') 3275 if not fstr.endswith('\n'): 3276 fstr += '\n' 3277 tree = ast.parse(fstr) 3278 d = {} 3279 key = None 3280 for node in ast.walk(tree): 3281 if isinstance(node,ast.Assign): 3282 key = node.targets[0].id 3283 d[key] = [config_example.__dict__.get(key), 3284 GSASIIpath.configDict.get(key), 3285 GSASIIpath.configDict.get(key),''] 3286 elif isinstance(node,ast.Expr) and key: 3287 d[key][3] = node.value.s.strip() 3288 else: 3289 key = None 3290 return d 3291 3292 def SaveConfigVars(vars,parent=None): 3293 '''Write the current config variable values to config.py 3294 3295 :params dict vars: a dictionary of variable settings and meanings as 3296 created in :func:`GetConfigValsDocs`. 3297 :param parent: wx.Frame object or None (default) for parent 3298 of error message if no file can be written. 3299 :returns: True if unable to write the file, None otherwise 3300 ''' 3301 # try to write to where an old config file is located 3302 try: 3303 import config 3304 savefile = config.__file__ 3305 except ImportError: # no config.py file yet 3306 savefile = os.path.join(GSASIIpath.path2GSAS2,'config.py') 3307 # try to open file for write 3308 try: 3309 savefile = os.path.splitext(savefile)[0]+'.py' # convert .pyc to .py 3310 fp = open(savefile,'w') 3311 except IOError: # can't write there, write in local mods directory 3312 # create a local mods directory, if needed 3313 if not os.path.exists(os.path.expanduser('~/.G2local/')): 3314 print('Creating directory '+os.path.expanduser('~/.G2local/')) 3315 os.mkdir(os.path.expanduser('~/.G2local/')) 3316 sys.path.insert(0,os.path.expanduser('~/.G2local/')) 3317 savefile = os.path.join(os.path.expanduser('~/.G2local/'),'config.py') 3318 try: 3319 fp = open(savefile,'w') 3320 except IOError: 3321 if parent: 3322 G2MessageBox(parent, 3323 'Error trying to write configuration to '+savefile, 3324 'Unable to save') 3325 else: 3326 print('Error trying to write configuration to '+savefile) 3327 return True 3328 import datetime 3329 fp.write("'''\n") 3330 fp.write("*config.py: Configuration options*\n----------------------------------\n") 3331 fp.write("This file created in SelectConfigSetting on {:%d %b %Y %H:%M}\n". 3332 format(datetime.datetime.now())) 3333 fp.write("'''\n\n") 3334 fp.write("import os.path\n") 3335 fp.write("import GSASIIpath\n\n") 3336 for var in sorted(vars.keys(),key=lambda s: s.lower()): 3337 if vars[var][1] is None: continue 3338 if vars[var][1] == '': continue 3339 if vars[var][0] == vars[var][1]: continue 3340 try: 3341 float(vars[var][1]) # test for number 3342 fp.write(var + ' = ' + str(vars[var][1])+'\n') 3343 except: 3344 try: 3345 eval(vars[var][1]) # test for an expression 3346 fp.write(var + ' = ' + str(vars[var][1])+'\n') 3347 except: # must be a string 3348 fp.write(var + ' = "' + str(vars[var][1])+'"\n') 3349 if vars[var][3]: 3350 fp.write("'''" + str(vars[var][3]) + "\n'''\n\n") 3351 fp.close() 3352 print('wrote file '+savefile) 3353 3152 3354 class SelectConfigSetting(wx.Dialog): 3153 3355 '''Dialog to select configuration variables and set associated values. 3154 3356 ''' 3155 3357 def __init__(self,parent=None): 3156 import config_example3157 3358 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER 3158 3359 wx.Dialog.__init__(self, parent, wx.ID_ANY, 'Set Config Variable', style=style) 3159 3360 self.sizer = wx.BoxSizer(wx.VERTICAL) 3160 self.vars = self.GetVarDocs(config_example.__file__)3361 self.vars = GetConfigValsDocs() 3161 3362 3162 3363 label = wx.StaticText( … … 3198 3399 self.CenterOnParent() 3199 3400 3200 def GetVarDocs(self,fname):3201 '''Read the module referenced in fname (often <module>.__file__) and3202 return a dict with names of global variables as keys.3203 For each global variable, the value contains four items:3204 3205 item 0: the default value3206 3207 item 1: the current value3208 3209 item 2: the initial value (starts same as item 1)3210 3211 item 3: the "docstring" that follows variable definition3212 '''3213 import config_example3214 import ast3215 fname = os.path.splitext(fname)[0]+'.py' # convert .pyc to .py3216 with open(fname, 'r') as f:3217 fstr = f.read()3218 fstr = fstr.replace('\r\n', '\n').replace('\r', '\n')3219 if not fstr.endswith('\n'):3220 fstr += '\n'3221 tree = ast.parse(fstr)3222 d = {}3223 key = None3224 for node in ast.walk(tree):3225 if isinstance(node,ast.Assign):3226 key = node.targets[0].id3227 d[key] = [config_example.__dict__.get(key),3228 GSASIIpath.configDict.get(key),3229 GSASIIpath.configDict.get(key),'']3230 elif isinstance(node,ast.Expr) and key:3231 d[key][3] = node.value.s.strip()3232 else:3233 key = None3234 return d3235 3236 3401 def OnChange(self,event=None): 3237 3402 ''' Check if anything been changed. Turn the save button on/off. … … 3263 3428 as the current settings 3264 3429 ''' 3265 # try to write to where an old config file is located 3266 try: 3267 import config 3268 savefile = config.__file__ 3269 except ImportError: # no config.py file yet 3270 savefile = os.path.join(GSASIIpath.path2GSAS2,'config.py') 3271 # try to open file for write 3272 try: 3273 savefile = os.path.splitext(savefile)[0]+'.py' # convert .pyc to .py 3274 fp = open(savefile,'w') 3275 except IOError: # can't write there, write in local mods directory 3276 # create a local mods directory, if needed 3277 if not os.path.exists(os.path.expanduser('~/.G2local/')): 3278 print('Creating directory '+os.path.expanduser('~/.G2local/')) 3279 os.mkdir(os.path.expanduser('~/.G2local/')) 3280 sys.path.insert(0,os.path.expanduser('~/.G2local/')) 3281 savefile = os.path.join(os.path.expanduser('~/.G2local/'),'config.py') 3282 try: 3283 fp = open(savefile,'w') 3284 except IOError: 3285 G2MessageBox(self, 3286 'Error trying to write configuration to '+savefile, 3287 'Unable to save') 3288 return 3289 import datetime 3290 fp.write("'''\n") 3291 fp.write("*config.py: Configuration options*\n----------------------------------\n") 3292 fp.write("This file created in SelectConfigSetting on {:%d %b %Y %H:%M}\n". 3293 format(datetime.datetime.now())) 3294 fp.write("'''\n\n") 3295 fp.write("import os.path\n") 3296 fp.write("import GSASIIpath\n\n") 3297 for var in sorted(self.vars.keys(),key=lambda s: s.lower()): 3298 if self.vars[var][1] is None: continue 3299 if self.vars[var][1] == '': continue 3300 if self.vars[var][0] == self.vars[var][1]: continue 3301 try: 3302 float(self.vars[var][1]) # test for number 3303 fp.write(var + ' = ' + str(self.vars[var][1])+'\n') 3304 except: 3305 try: 3306 eval(self.vars[var][1]) # test for an expression 3307 fp.write(var + ' = ' + str(self.vars[var][1])+'\n') 3308 except: # must be a string 3309 fp.write(var + ' = "' + str(self.vars[var][1])+'"\n') 3310 if self.vars[var][3]: 3311 fp.write("'''" + str(self.vars[var][3]) + "\n'''\n\n") 3312 fp.close() 3313 print('wrote file '+savefile) 3314 # force a reload of the config settings 3315 self.OnApplyChanges() 3316 self.EndModal(wx.ID_OK) 3430 if not SaveConfigVars(self.vars,parent=self): 3431 self.OnApplyChanges() # force a reload of the config settings 3432 self.EndModal(wx.ID_OK) 3317 3433 3318 3434 def OnBoolSelect(self,event): … … 3638 3754 ) 3639 3755 if GSASIIpath.GetConfigValue('Tutorial_location'): 3640 tutorialPath = GSASIIpath.GetConfigValue('Tutorial_location')3756 tutorialPath = os.path.abspath(GSASIIpath.GetConfigValue('Tutorial_location')) 3641 3757 else: 3642 3758 # pick a default directory in a logical place … … 3786 3902 self.LoadExercise(exedir,tutorialPath,G2BaseURL) 3787 3903 URL = os.path.join(tutorialPath,'help',tutdir,htmlname) 3788 self.frame. ImportDir = os.path.join(tutorialPath,'Exercises',exedir)3904 self.frame.TutorialImportDir = os.path.join(tutorialPath,'Exercises',exedir) 3789 3905 ShowWebPage(URL,self.frame) 3790 3906 elif self.BrowseMode == 1: … … 3792 3908 self.LoadExercise(exedir,tutorialPath,G2BaseURL) 3793 3909 URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname) 3794 self.frame. ImportDir = os.path.join(tutorialPath,'Exercises',exedir)3910 self.frame.TutorialImportDir = os.path.join(tutorialPath,'Exercises',exedir) 3795 3911 ShowWebPage(URL,self.frame) 3796 3912 elif self.BrowseMode == 2: … … 3801 3917 # open web page that has already been transferred 3802 3918 URL = os.path.join(tutorialPath,'help',tutdir,htmlname) 3803 self.frame. ImportDir = os.path.join(tutorialPath,'Exercises',exedir)3919 self.frame.TutorialImportDir = os.path.join(tutorialPath,'Exercises',exedir) 3804 3920 ShowWebPage(URL,self.frame) 3805 3921 else: -
trunk/GSASIIgrid.py
r2082 r2109 1967 1967 else: 1968 1968 wild = 'Text output file (*.txt)|*.txt' 1969 pth = G2G.GetExportPath(G2frame) 1969 1970 dlg = wx.FileDialog( 1970 1971 G2frame, 1971 'Choose text output file for your selection', '.', '',1972 wild,wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT |wx.CHANGE_DIR)1972 'Choose text output file for your selection', pth, '', 1973 wild,wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1973 1974 try: 1974 1975 if dlg.ShowModal() == wx.ID_OK: -
trunk/GSASIIimgGUI.py
r2108 r2109 298 298 299 299 def OnSaveControls(event): 300 dlg = wx.FileDialog(G2frame, 'Choose image controls file', '.', '', 301 'image control files (*.imctrl)|*.imctrl',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 300 pth = G2G.GetExportPath(G2frame) 301 dlg = wx.FileDialog(G2frame, 'Choose image controls file', pth, '', 302 'image control files (*.imctrl)|*.imctrl',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 302 303 try: 303 304 if dlg.ShowModal() == wx.ID_OK: … … 324 325 'calibskip','pixLimit','cutoff','calibdmin','chisq','Flat Bkg', 325 326 'PolaVal','SampleAbs','dark image','background image'] 326 dlg = wx.FileDialog(G2frame, 'Choose image controls file', '.', '', 327 'image control files (*.imctrl)|*.imctrl',wx.OPEN|wx.CHANGE_DIR) 327 pth = G2G.GetImportPath(G2frame) 328 if not pth: pth = '.' 329 dlg = wx.FileDialog(G2frame, 'Choose image controls file', pth, '', 330 'image control files (*.imctrl)|*.imctrl',wx.OPEN) 328 331 try: 329 332 if dlg.ShowModal() == wx.ID_OK: … … 1189 1192 def OnSaveMask(event): 1190 1193 CleanupMasks(data) 1191 dlg = wx.FileDialog(G2frame, 'Choose image mask file', '.', '', 1192 'image mask files (*.immask)|*.immask',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 1194 pth = G2G.GetExportPath(G2frame) 1195 dlg = wx.FileDialog(G2frame, 'Choose image mask file', pth, '', 1196 'image mask files (*.immask)|*.immask',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1193 1197 try: 1194 1198 if dlg.ShowModal() == wx.ID_OK: … … 1208 1212 else: 1209 1213 ignoreThreshold = False 1210 dlg = wx.FileDialog(G2frame, 'Choose image mask file', '.', '', 1211 'image mask files (*.immask)|*.immask',wx.OPEN|wx.CHANGE_DIR) 1214 pth = G2G.GetImportPath(G2frame) 1215 if not pth: pth = '.' 1216 dlg = wx.FileDialog(G2frame, 'Choose image mask file', pth, '', 1217 'image mask files (*.immask)|*.immask',wx.OPEN) 1212 1218 try: 1213 1219 if dlg.ShowModal() == wx.ID_OK: … … 1503 1509 1504 1510 def OnLoadStrSta(event): 1505 dlg = wx.FileDialog(G2frame, 'Choose stress/strain file', '.', '', 1506 'image control files (*.strsta)|*.strsta',wx.OPEN|wx.CHANGE_DIR) 1511 pth = G2G.GetImportPath(G2frame) 1512 if not pth: pth = '.' 1513 dlg = wx.FileDialog(G2frame, 'Choose stress/strain file', pth, '', 1514 'image control files (*.strsta)|*.strsta',wx.OPEN) 1507 1515 try: 1508 1516 if dlg.ShowModal() == wx.ID_OK: … … 1522 1530 1523 1531 def OnSaveStrSta(event): 1524 dlg = wx.FileDialog(G2frame, 'Choose stress/strain file', '.', '', 1525 'image control files (*.strsta)|*.strsta',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 1532 pth = G2G.GetExportPath(G2frame) 1533 dlg = wx.FileDialog(G2frame, 'Choose stress/strain file', pth, '', 1534 'image control files (*.strsta)|*.strsta',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1526 1535 try: 1527 1536 if dlg.ShowModal() == wx.ID_OK: … … 1550 1559 def OnStrStaSample(event): 1551 1560 filename = '' 1552 dlg = wx.FileDialog(G2frame, 'Choose multihistogram metadata text file', '.', '', 1553 'metadata file (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR) 1561 pth = G2G.GetImportPath(G2frame) 1562 if not pth: pth = '.' 1563 dlg = wx.FileDialog(G2frame, 'Choose multihistogram metadata text file', pth, '', 1564 'metadata file (*.*)|*.*',wx.OPEN) 1554 1565 try: 1555 1566 if dlg.ShowModal() == wx.ID_OK: … … 2544 2555 files = [] 2545 2556 try: 2546 dlg = wx.FileDialog(self, 'Select image control files or previous table', 2557 pth = G2G.GetImportPath(G2frame) 2558 if not pth: pth = '.' 2559 dlg = wx.FileDialog(self, 'Select image control files or previous table', pth, 2547 2560 style=wx.OPEN| wx.MULTIPLE, 2548 2561 wildcard='image control files (.imctrl)|*.imctrl|Integration table (*.imtbl)|*.imtbl') … … 2662 2675 fil = os.path.splitext(self.G2frame.GSASprojectfile)[0]+'.imtbl' 2663 2676 dir,f = os.path.split(fil) 2677 pth = G2G.GetExportPath(self.G2frame) 2664 2678 try: 2665 2679 dlg = wx.FileDialog(self, 'Save table data as', 2666 defaultDir= dir, defaultFile=f, style=wx.SAVE,2680 defaultDir=pth, defaultFile=f, style=wx.SAVE, 2667 2681 wildcard='G2 Image Param Table file (*.imtbl)|*.imtbl') 2668 2682 dlg.CenterOnParent() … … 2713 2727 self.CloseEditor() 2714 2728 fil = '(none)' 2729 pth = G2G.GetImportPath(self.parent.G2frame) 2730 if not pth: pth = '.' 2715 2731 try: 2716 dlg = wx.FileDialog(self, 'Select mask or control file to add (Press cancel if none)', 2732 dlg = wx.FileDialog(self, 'Select mask or control file to add (Press cancel if none)', pth, 2717 2733 style=wx.OPEN, 2718 2734 wildcard='Add GSAS-II mask file (.immask)|*.immask|add image control file (.imctrl)|*.imctrl') -
trunk/GSASIIphsGUI.py
r2100 r2109 3761 3761 ODFln = G2lat.Flnh(True,SHCoef,phi,beta,SGData) 3762 3762 pfName = PhaseName+'%d%d%d.gpf'%(PH[0],PH[1],PH[2]) 3763 dlg = wx.FileDialog(G2frame, 'Choose popLA pole figure file name', '.', pfName, 3764 'popLA file (*.gpf)|*.gpf',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 3763 pth = G2G.GetExportPath(G2frame) 3764 dlg = wx.FileDialog(G2frame, 'Choose popLA pole figure file name', pth, pfName, 3765 'popLA file (*.gpf)|*.gpf',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3765 3766 try: 3766 3767 if dlg.ShowModal() == wx.ID_OK: … … 3801 3802 IODFln = G2lat.Glnh(True,SHCoef,psi,gam,SamSym[textureData['Model']]) 3802 3803 pfName = PhaseName+'%d%d%dIPF.csv'%(int(PX[0]),int(PX[1]),int(PX[2])) 3803 dlg = wx.FileDialog(G2frame, 'Choose CSV inverse pole figure file name', '.', pfName, 3804 'CSV file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 3804 pth = G2G.GetExportPath(G2frame) 3805 dlg = wx.FileDialog(G2frame, 'Choose CSV inverse pole figure file name', pth, pfName, 3806 'CSV file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3805 3807 else: 3806 3808 PH = np.array(textureData['PFhkl']) … … 3809 3811 ODFln = G2lat.Flnh(True,SHCoef,phi,beta,SGData) 3810 3812 pfName = PhaseName+'%d%d%dPF.csv'%(PH[0],PH[1],PH[2]) 3811 dlg = wx.FileDialog(G2frame, 'Choose CSV pole figure file name', '.', pfName, 3812 'CSV file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 3813 pth = G2G.GetExportPath(G2frame) 3814 dlg = wx.FileDialog(G2frame, 'Choose CSV pole figure file name', pth, pfName, 3815 'CSV file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3813 3816 try: 3814 3817 if dlg.ShowModal() == wx.ID_OK: -
trunk/GSASIIpwdGUI.py
r2090 r2109 1255 1255 Note that similar code is found in ReadPowderInstprm (GSASII.py) 1256 1256 ''' 1257 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II instrument parameters file', '.', '', 1258 'instrument parameter files (*.instprm)|*.instprm',wx.OPEN|wx.CHANGE_DIR) 1257 pth = G2G.GetImportPath(G2frame) 1258 if not pth: pth = '.' 1259 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II instrument parameters file', pth, '', 1260 'instrument parameter files (*.instprm)|*.instprm',wx.OPEN) 1259 1261 try: 1260 1262 if dlg.ShowModal() == wx.ID_OK: … … 1291 1293 item: writes current parameters to a .instprm file 1292 1294 ''' 1293 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II instrument parameters file', '.', '', 1294 'instrument parameter files (*.instprm)|*.instprm',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 1295 pth = G2G.GetExportPath(G2frame) 1296 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II instrument parameters file', pth, '', 1297 'instrument parameter files (*.instprm)|*.instprm',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1295 1298 try: 1296 1299 if dlg.ShowModal() == wx.ID_OK: … … 1750 1753 item: writes current parameters to a .samprm file 1751 1754 ''' 1752 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II sample parameters file', '.', '', 1753 'sample parameter files (*.samprm)|*.samprm',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 1755 pth = G2G.GetExportPath(G2frame) 1756 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II sample parameters file', pth, '', 1757 'sample parameter files (*.samprm)|*.samprm',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 1754 1758 try: 1755 1759 if dlg.ShowModal() == wx.ID_OK: … … 1773 1777 Note that similar code is found in ReadPowderInstprm (GSASII.py) 1774 1778 ''' 1775 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II sample parameters file', '.', '', 1776 'sample parameter files (*.samprm)|*.samprm',wx.OPEN|wx.CHANGE_DIR) 1779 pth = G2G.GetImportPath(G2frame) 1780 if not pth: pth = '.' 1781 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II sample parameters file', pth, '', 1782 'sample parameter files (*.samprm)|*.samprm',wx.OPEN) 1777 1783 try: 1778 1784 if dlg.ShowModal() == wx.ID_OK: … … 1797 1803 def OnAllSampleLoad(event): 1798 1804 filename = '' 1799 dlg = wx.FileDialog(G2frame, 'Choose multihistogram metadata text file', '.', '', 1800 'metadata file (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR) 1805 pth = G2G.GetImportPath(G2frame) 1806 if not pth: pth = '.' 1807 dlg = wx.FileDialog(G2frame, 'Choose multihistogram metadata text file', pth, '', 1808 'metadata file (*.*)|*.*',wx.OPEN) 1801 1809 try: 1802 1810 if dlg.ShowModal() == wx.ID_OK: … … 2559 2567 2560 2568 def OnExportCells(event): 2561 dlg = wx.FileDialog(G2frame, 'Choose Indexing Result csv file', '.', '', 2562 'indexing result file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 2569 pth = G2G.GetExportPath(G2frame) 2570 dlg = wx.FileDialog(G2frame, 'Choose Indexing Result csv file', pth, '', 2571 'indexing result file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 2563 2572 try: 2564 2573 if dlg.ShowModal() == wx.ID_OK: -
trunk/config_example.py
r2003 r2109 68 68 As another example, to use ~/.G2tutorials do this:: 69 69 70 Tutorial_location = os.path.expanduser('~/.G2tutorials')70 Tutorial_location = '~/.G2tutorials' 71 71 72 Note that os.path and GSASIIpath are imported inside config.py; other imports will 73 require manual editing of the file. 72 Note that os.path.expanduser is run on Tutorial_location before it is used. 73 Also note that GSASIIpath is imported inside config.py; other imports should be 74 avoided. 75 ''' 76 77 Save_paths=False 78 '''When set to True, the last-used path for saving of .gpx and for 79 importing of input files is saved in the configuration file. 80 Note that since this causes the config.py file to be updated whenever files are 81 saved/imported, any temporary config settings can be saved to disk at that 82 point. 74 83 ''' 75 84 76 85 Starting_directory=None 77 '''Specifies a default location for starting GSAS-II 86 '''Specifies a default location for starting GSAS-II and where .gpx files 87 should be read from. Will be updated if Save_paths is True. 88 Note that os.path.expanduser is run on this before it is used, so the user's 89 home directory can be specified with a '~'. 78 90 ''' 79 91 80 92 Import_directory=None 81 '''Specifies a default location for finding exercise files used for 82 Tutorials. 93 '''Specifies a default location for importing (reading) input files. Will be 94 updated if Save_paths is True. 95 Note that os.path.expanduser is run on this before it is used, so the user's 96 home directory can be specified with a '~'. 83 97 ''' 84 98 -
trunk/exports/G2export_CIF.py
r1831 r2109 2235 2235 def _onSave(self,event): 2236 2236 'Save CIF entries in a template file' 2237 pth = G2G.GetExportPath(self.G2frame) 2237 2238 dlg = wx.FileDialog( 2238 2239 self, message="Save as CIF template", 2239 defaultDir= os.getcwd(),2240 defaultDir=pth, 2240 2241 defaultFile=self.defaultname, 2241 2242 wildcard="CIF (*.cif)|*.cif", 2242 style=wx.SAVE | wx.CHANGE_DIR 2243 ) 2243 style=wx.SAVE) 2244 2244 val = (dlg.ShowModal() == wx.ID_OK) 2245 2245 fil = dlg.GetPath() … … 2550 2550 def _onGetTemplateFile(self,event): 2551 2551 'select a template file' 2552 pth = G2G.GetImportPath(self.G2frame) 2553 if not pth: pth = '.' 2552 2554 dlg = wx.FileDialog( 2553 2555 self.cifdefs, message="Read CIF template file", 2554 defaultDir= os.getcwd(),2556 defaultDir=pth, 2555 2557 defaultFile=self.defaultname, 2556 2558 wildcard="CIF (*.cif)|*.cif", 2557 style=wx.OPEN | wx.CHANGE_DIR 2558 ) 2559 style=wx.OPEN) 2559 2560 ret = dlg.ShowModal() 2560 2561 fil = dlg.GetPath()
Note: See TracChangeset
for help on using the changeset viewer.