Changes in src/sas/sasgui/guiframe/gui_manager.py [8ac05a5:9220e89c] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/gui_manager.py
r8ac05a5 r9220e89c 46 46 from sas.sasgui.guiframe.CategoryManager import CategoryManager 47 47 from sas.sascalc.dataloader.loader import Loader 48 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 48 49 from sas.sasgui.guiframe.proxy import Connection 49 50 … … 2419 2420 default_name = fname 2420 2421 wildcard = "Text files (*.txt)|*.txt|"\ 2421 "CanSAS 1D files(*.xml)|*.xml" 2422 path = None 2422 "CanSAS 1D files (*.xml)|*.xml|"\ 2423 "NXcanSAS files (*.h5)|*.h5|" 2424 options = [".txt", ".xml",".h5"] 2423 2425 dlg = wx.FileDialog(self, "Choose a file", 2424 2426 self._default_save_location, … … 2430 2432 # This is MAC Fix 2431 2433 ext_num = dlg.GetFilterIndex() 2432 if ext_num == 0: 2433 ext_format = '.txt' 2434 else: 2435 ext_format = '.xml' 2434 2435 ext_format = options[ext_num] 2436 2436 path = os.path.splitext(path)[0] + ext_format 2437 2437 mypath = os.path.basename(path) 2438 2439 # Instantiate a loader 2440 loader = Loader() 2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2438 fName = os.path.splitext(path)[0] + ext_format 2439 2440 if os.path.splitext(mypath)[1].lower() == options[0]: 2443 2441 # Make sure the ext included in the file name 2444 2442 # especially on MAC 2445 fName = os.path.splitext(path)[0] + ext_format2446 2443 self._onsaveTXT(data, fName) 2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2444 elif os.path.splitext(mypath)[1].lower() == options[1]: 2449 2445 # Make sure the ext included in the file name 2450 2446 # especially on MAC 2451 fName = os.path.splitext(path)[0] + ext_format 2447 # Instantiate a loader 2448 loader = Loader() 2452 2449 loader.save(fName, data, ext_format) 2450 elif os.path.splitext(mypath)[1].lower() == options[2]: 2451 nxcansaswriter = NXcanSASWriter() 2452 nxcansaswriter.write([data], fName) 2453 2453 try: 2454 2454 self._default_save_location = os.path.dirname(path) … … 2477 2477 if has_errors: 2478 2478 if data.dx is not None and data.dx != []: 2479 out.write("<X> <Y> <dY><dX>\n")2479 out.write("<X>\t<Y>\t<dY>\t<dX>\n") 2480 2480 else: 2481 out.write("<X> <Y><dY>\n")2481 out.write("<X>\t<Y>\t<dY>\n") 2482 2482 else: 2483 out.write("<X> 2483 out.write("<X>\t<Y>\n") 2484 2484 2485 2485 for i in range(len(data.x)): … … 2525 2525 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2526 2526 text += '\nData Points:\n' 2527 x_st = "X" 2527 text += "<index> \t<X> \t<Y> \t<dY> " 2528 text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 2529 data.dxw is not None) else "\t<dX>\n" 2528 2530 for index in range(len(data.x)): 2529 2531 if data.dy is not None and len(data.dy) > index: … … 2536 2538 dx_val = 0.0 2537 2539 if data.dxl is not None and len(data.dxl) > index: 2538 if index == 0:2539 x_st = "Xl"2540 2540 dx_val = data.dxl[index] 2541 elif data.dxw is not None and len(data.dxw) > index: 2542 if index == 0: 2543 x_st = "Xw" 2544 dx_val = data.dxw[index] 2545 2546 if index == 0: 2547 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2541 if data.dxw is not None and len(data.dxw) > index: 2542 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2543 2548 2544 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2549 2545 data.x[index], … … 2562 2558 """ 2563 2559 default_name = fname 2564 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2560 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2561 "NXcanSAS files (*.h5)|*.h5|" 2565 2562 dlg = wx.FileDialog(self, "Choose a file", 2566 2563 self._default_save_location, … … 2574 2571 if ext_num == 0: 2575 2572 ext_format = '.dat' 2573 elif ext_num == 1: 2574 ext_format = '.h5' 2576 2575 else: 2577 2576 ext_format = '' … … 2581 2580 # Instantiate a loader 2582 2581 loader = Loader() 2583 2584 ext_format = ".dat" 2585 if os.path.splitext(mypath)[1].lower() == ext_format: 2582 ext = os.path.splitext(mypath)[1].lower() 2583 if ext == '.dat': 2586 2584 # Make sure the ext included in the file name 2587 2585 # especially on MAC 2588 2586 fileName = os.path.splitext(path)[0] + ext_format 2589 2587 loader.save(fileName, data, ext_format) 2588 elif ext == '.h5': 2589 # Make sure the ext included in the file name 2590 # especially on MAC 2591 fileName = os.path.splitext(path)[0] + ext_format 2592 nxcansaswriter = NXcanSASWriter() 2593 nxcansaswriter.write([data], fileName) 2590 2594 try: 2591 2595 self._default_save_location = os.path.dirname(path)
Note: See TracChangeset
for help on using the changeset viewer.