Changeset 9a0fc50 in sasview for src/sas/sasgui/guiframe/gui_manager.py
- Timestamp:
- Sep 13, 2018 2:31:36 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
- Children:
- 43313e72
- Parents:
- feec1cb (diff), 356af60e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/gui_manager.py
rb963b20 rfeec1cb 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 … … 2422 2423 default_name = fname 2423 2424 wildcard = "Text files (*.txt)|*.txt|"\ 2424 "CanSAS 1D files(*.xml)|*.xml" 2425 path = None 2425 "CanSAS 1D files (*.xml)|*.xml|"\ 2426 "NXcanSAS files (*.h5)|*.h5|" 2427 options = {0: ".txt", 2428 1: ".xml", 2429 2: ".h5"} 2426 2430 dlg = wx.FileDialog(self, "Choose a file", 2427 2431 self._default_save_location, … … 2433 2437 # This is MAC Fix 2434 2438 ext_num = dlg.GetFilterIndex() 2435 if ext_num == 0: 2436 ext_format = '.txt' 2437 else: 2438 ext_format = '.xml' 2439 2440 ext_format = options[ext_num] 2439 2441 path = os.path.splitext(path)[0] + ext_format 2440 2442 mypath = os.path.basename(path) 2441 2442 # Instantiate a loader 2443 loader = Loader() 2444 ext_format = ".txt" 2445 if os.path.splitext(mypath)[1].lower() == ext_format: 2443 fName = os.path.splitext(path)[0] + ext_format 2444 2445 if os.path.splitext(mypath)[1].lower() == options[0]: 2446 2446 # Make sure the ext included in the file name 2447 2447 # especially on MAC 2448 fName = os.path.splitext(path)[0] + ext_format2449 2448 self._onsaveTXT(data, fName) 2450 ext_format = ".xml" 2451 if os.path.splitext(mypath)[1].lower() == ext_format: 2449 elif os.path.splitext(mypath)[1].lower() == options[1]: 2452 2450 # Make sure the ext included in the file name 2453 2451 # especially on MAC 2454 fName = os.path.splitext(path)[0] + ext_format 2452 # Instantiate a loader 2453 loader = Loader() 2455 2454 loader.save(fName, data, ext_format) 2455 elif os.path.splitext(mypath)[1].lower() == options[2]: 2456 nxcansaswriter = NXcanSASWriter() 2457 nxcansaswriter.write([data], fName) 2456 2458 try: 2457 2459 self._default_save_location = os.path.dirname(path) … … 2528 2530 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2529 2531 text += '\nData Points:\n' 2530 x_st = "X" 2532 text += "<index> \t<X> \t<Y> \t<dY> \t<dX" 2533 if data.dxl is not None and data.dxw is not None: 2534 text += "l> \t<dxw" 2535 text += ">\n" 2531 2536 for index in range(len(data.x)): 2532 2537 if data.dy is not None and len(data.dy) > index: … … 2539 2544 dx_val = 0.0 2540 2545 if data.dxl is not None and len(data.dxl) > index: 2541 if index == 0:2542 x_st = "Xl"2543 2546 dx_val = data.dxl[index] 2544 elif data.dxw is not None and len(data.dxw) > index: 2545 if index == 0: 2546 x_st = "Xw" 2547 dx_val = data.dxw[index] 2548 2549 if index == 0: 2550 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2547 if data.dxw is not None and len(data.dxw) > index: 2548 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2549 2551 2550 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2552 2551 data.x[index], … … 2565 2564 """ 2566 2565 default_name = fname 2567 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2566 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2567 "NXcanSAS files (*.h5)|*.h5|" 2568 2568 dlg = wx.FileDialog(self, "Choose a file", 2569 2569 self._default_save_location, … … 2577 2577 if ext_num == 0: 2578 2578 ext_format = '.dat' 2579 elif ext_num == 1: 2580 ext_format = '.h5' 2579 2581 else: 2580 2582 ext_format = '' … … 2584 2586 # Instantiate a loader 2585 2587 loader = Loader() 2586 2587 ext_format = ".dat" 2588 if os.path.splitext(mypath)[1].lower() == ext_format: 2588 if os.path.splitext(mypath)[1].lower() == '.dat': 2589 2589 # Make sure the ext included in the file name 2590 2590 # especially on MAC 2591 2591 fileName = os.path.splitext(path)[0] + ext_format 2592 2592 loader.save(fileName, data, ext_format) 2593 elif os.path.splitext(mypath)[1].lower() == '.h5': 2594 # Make sure the ext included in the file name 2595 # especially on MAC 2596 fileName = os.path.splitext(path)[0] + ext_format 2597 nxcansaswriter = NXcanSASWriter() 2598 nxcansaswriter.write([data], fileName) 2593 2599 try: 2594 2600 self._default_save_location = os.path.dirname(path)
Note: See TracChangeset
for help on using the changeset viewer.