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